Set up workload identity
A workload identity represents your gateway as a distinct, recognizable identity when it accesses tools and other resources. This topic explains the two types of workload identity that a gateway can have, and how to set up IAM Agent and workload identity (Preview) before you create a gateway.
Workload identity types for a gateway
A gateway has one of the following types of workload identity:
- AgentCore Identity workload identity
-
AgentCore creates this workload identity automatically when you create a gateway that doesn’t use IAM Agent and workload identity. You don’t need to set it up. For more information, see Understanding workload identities.
- IAM Agent and workload identity (Preview)
-
An optional identity that AWS Identity and Access Management (IAM) issues to your gateway, in a name space that you own. When you turn it on, it replaces the AgentCore Identity workload identity. AgentCore attests the gateway’s name and ID, and IAM builds the gateway’s identifier from them, for example
spiffe://111122223333.aws.internal/us-west-2/bedrock-agentcore/gateway/payments-tools/payments-tools-a1b2c3d4e5. The identity doesn’t replace the gateway service role. The role still defines what the gateway can do, and the identity says which gateway is acting.ImportantIAM Agent and workload identity is in preview release for AWS Identity and Access Management (IAM) and is subject to change.
With IAM Agent and workload identity turned on, your gateway can do the following:
-
Carry its identity to AWS services – The gateway’s service role sessions carry the identity when the gateway calls IAM-authorized targets and dependencies. IAM and resource-based policies can match it with the
aws:OriginIdentity/Subjectandaws:OriginIdentity/Issuercondition keys, and AWS CloudTrail records it. -
Authenticate to targets without stored credentials – The gateway can present its identity to MCP server, OpenAPI, AgentCore Runtime, and HTTP passthrough targets as a short-lived JSON Web Token SPIFFE Verifiable Identity Document (JWT-SVID). For more information, see Set up outbound authorization for your gateway.
-
You turn on IAM Agent and workload identity when you create a gateway. You can’t turn it on for an existing gateway, and you can’t turn it off after you create the gateway. You can choose a different template later with
UpdateGateway. -
Gateway supports JWT-SVIDs only, not X.509-SVIDs.
To set up IAM Agent and workload identity, you create a workload identity provider and a workload identity template in IAM, and the template’s attestation policy must allow AgentCore to attest your gateways. If you create the gateway in the AWS Management Console, you can let AgentCore create the provider and template for you. For more information, see Agent and workload identity (Preview) in the IAM User Guide.
The workload identity provider, workload identity template, and attestation policy described in the following sections apply only to IAM Agent and workload identity. You don’t need any of them for the AgentCore Identity workload identity, which AgentCore creates and manages for you.
Workload identity provider
A workload identity provider is the issuer for all of the identities that IAM Agent and workload identity issues. It sets the naming scheme and the trust domain, such as corp.example.com, that every identifier under it starts with. The provider’s ARN is the value of the aws:OriginIdentity/Issuer condition key, and its JSON Web Key Set (JWKS) is what a target uses to verify the gateway’s JWT-SVIDs.
You can create a provider in one account or for your whole organization in AWS Organizations:
-
Account-level provider – Issues identities for workloads in one account. Its ARN has the form
arn:aws:iam::111122223333:workload-identity-provider/name. -
Organization-level provider – Issues identities for workloads across the accounts in your organization. Its ARN has the form
arn:aws:iam::o-a1b2c3d4e5:workload-identity-provider/name.
To use JWT-SVID outbound authorization, the provider must use the SPIFFE scheme. You choose the scheme when you create the provider and can’t change it.
If you use the console’s Auto-configure setup option when you create a gateway, AgentCore uses the provider named default, with the trust domain <account-id>.aws.internal, and creates it if it doesn’t exist. If your account can read an organization-level provider, the console uses that provider instead.
For the steps to create a provider, see Create a workload identity provider in the IAM User Guide.
Workload identity template
A workload identity template defines how IAM names each gateway. It combines a path prefix, which is the part of the provider’s name space that the template sits in, with a path pattern that IAM fills in with the facts that AgentCore attests about the gateway. You can create one template for all of your gateways, because each gateway’s identifier includes its own name and ID.
The simplest way to create a gateway template is from an AWS-owned template definition, which provides the path pattern and the attestation policy for you. AgentCore publishes the following definitions for gateways:
| Provider | Definition | Identifier |
|---|---|---|
|
Account-level |
|
|
|
Organization-level |
|
|
The following example creates a template from the account-level definition:
aws iam create-workload-identity-template \ --template-definition '{ "TemplateDefinitionArn": "arn:aws:iam::aws:workload-identity-template-definition/bedrock-agentcore.amazonaws.com/gateway/account-provider-default:1", "ReplacementValues": { "Name": { "Values": ["agentcore-gateways"] }, "WorkloadIdentityProviderArn": { "Values": ["arn:aws:iam::111122223333:workload-identity-provider/default"] } } }'
The identifier includes the gateway ID, so a gateway that you delete and re-create with the same name receives a different identifier and doesn’t inherit the old gateway’s access. To grant access to a gateway and every re-creation of it, match its name followed by /
, for example spiffe://111122223333.aws.internal/us-west-2/bedrock-agentcore/gateway/payments-tools/.
When you create the gateway, specify the template’s ARN in the workloadIdentityTemplateArn field. For examples, see Create a gateway with IAM Agent and workload identity (Preview).
For more information about templates, including how to write your own path pattern, see Create workload identity templates in the IAM User Guide.
Attestation policy
An attestation policy is a policy on the template that decides which AWS service can vouch for a workload and which facts about the workload must match. Without an attestation policy, IAM doesn’t issue an identity. For a gateway, AgentCore attests the gateway, so the attestation policy must allow the bedrock-agentcore.amazonaws.com service principal to call sts:IssueWorkloadIdentityContext.
If you create the template from a gateway/ definition, the definition writes the attestation policy for you. If you write your own template, attach an attestation policy such as the following, which allows AgentCore to attest gateways in your account:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowAgentCoreGatewayAttestation", "Effect": "Allow", "Principal": { "Service": "bedrock-agentcore.amazonaws.com" }, "Action": "sts:IssueWorkloadIdentityContext", "Condition": { "StringEquals": { "aws:SourceAccount": "111122223333" } } } ] }
To limit the template to specific gateways, add conditions on the facts that AgentCore attests, such as the aws:WorkloadAttestation/aws/bedrock-agentcore/GatewayId condition key. For the attestation keys and examples, see Write attestation policies in the IAM User Guide.
If the attestation policy doesn’t allow AgentCore to attest the gateway, or the template or provider doesn’t exist, calls that the gateway makes with its identity fail with an access denied error. Calls to targets that use the gateway service role, AgentCore Identity, or a customer-managed AWS KMS key are affected.
Permissions
-
The identity that creates or updates the gateway needs
iam:PassWorkloadIdentityTemplateon the template, with theiam:PassedToServicecondition key set tobedrock-agentcore.amazonaws.com. -
The role trust policy of the gateway service role doesn’t change.
-
To authenticate to targets with a JWT-SVID, the gateway service role needs
sts:GetWebIdentityToken.
For example policies, see Set up permissions for AgentCore Gateway.