

# Getting started with agent and workload identity

**Preview release**  
Agent and workload identity is in preview release for AWS Identity and Access Management (IAM) and is subject to change.

In this guide, you give a workload in an Amazon Elastic Kubernetes Service (Amazon EKS) cluster its own identity, and then use that identity in three ways:
+ Call an AWS service. You write an Amazon Simple Storage Service (Amazon S3) bucket policy that allows only this workload. The pod can read the bucket because its role session carries the workload's identifier and provider, and the bucket policy authorizes both.
+ Call a service outside AWS. The pod gets a JSON Web Token (JWT) with an audience that you choose. The external service verifies it with your provider's public keys.
+ Use mutual TLS. The pod gets an X.509 certificate that's signed by your own AWS Private Certificate Authority (AWS Private CA). This part is optional.

Finally, you use AWS CloudTrail to find each of these calls.

Steps 1 through 4 mostly use the AWS Management Console. Steps 5 and 6 mostly use the AWS Command Line Interface (AWS CLI). Step 7 uses the AWS CloudTrail console. Run the commands marked From the pod inside the workload's container, for example with `kubectl exec -n payments -it <pod-name> -- sh`.

**Time to complete:** About 30 minutes without step 6. With step 6, allow a little over 1 hour, because a new CA starts signing 1 hour after you attach it. Attach it right after step 1, and the wait runs while you do the other steps.

**Cost:** Identities for agents and workloads are offered at no additional charge during the preview. Step 6 uses AWS Private CA, which charges for the certificate authority (CA) and the certificates it issues. For more information, see AWS Private CA pricing.

**Note**  
The steps are similar for agents and gateways on Amazon Bedrock AgentCore: you create a provider and a template, and turn on agent and workload identity when you create the runtime or gateway. See Amazon Bedrock AgentCore.

## Prerequisites
<a name="wi-gs-prerequisites"></a>
+ An Amazon EKS cluster with at least one workload that uses EKS Pod Identity, and the IAM role that the workload uses. In this guide, the cluster is `prod-cluster-1` in `us-east-1`, the workload runs in namespace `payments` with service account `checkout-sa`, and the role is `eks-pod-identity-role` in account `111122223333`.
+ The EKS Pod Identity Agent add-on, version v1.5.0-eksbuild.3 or later, installed on the cluster. EKS Auto Mode includes the Pod Identity Agent. For agent and workload identity, Auto Mode nodes need an Auto Mode AMI released on or after November 18, 2026.
+ The AWS CLI and OpenSSL in the workload's container image.
+ An S3 bucket in the same account as the role, with a test object. In this guide, the bucket is `amzn-s3-demo-bucket` and the object is `orders/hello.txt`.
+ For step 6 only: a multi-Region AWS Private CA in service-affiliated mode for agent and workload identity, replicated to us-east-1. If your cluster runs in a different Region, also replicate the CA to that Region. For details, see [Configure signing and the trust bundle](workload-identity-signing-trust-bundle.md).
+ Permissions for the following actions. For an example policy, see Example policies.
  + `iam:CreateWorkloadIdentityProvider`
  + `iam:CreateWorkloadIdentityTemplate` and `iam:PutWorkloadIdentityTemplateAttestationPolicy`. The template definition writes an attestation policy, so you need the put action too.
  + `iam:PutRolePolicy` on the workload's role
  + To set the template on the Pod Identity association: `iam:PassWorkloadIdentityTemplate`, `iam:GetWorkloadIdentityTemplate`, and `iam:GetWorkloadIdentityTemplateAttestationPolicy` on the template, and `iam:GetWorkloadIdentityProvider` on the provider. You use the last one again in step 5, to find the provider's issuer URL.
  + `eks:UpdatePodIdentityAssociation`, and `iam:PassRole` and `iam:GetRole` on `eks-pod-identity-role`
  + `s3:PutBucketPolicy` on the bucket
  + For step 6: `iam:CreateWorkloadIdentityProviderOutboundSigner` on the provider, and `acm-pca:GetCertificateAuthorityCertificate`, `acm-pca:DescribeCertificateAuthority`, `acm-pca:CreateCertificateAuthorityAssociation`, and `acm-pca:DeleteCertificateAuthorityAssociation` on the CA
  + For clean up: `iam:DeleteRolePolicy`, `iam:DeleteWorkloadIdentityTemplate`, and `iam:DeleteWorkloadIdentityProvider`. If you did step 6, also `iam:DisableWorkloadIdentityProviderOutboundSigner` and `iam:DeleteWorkloadIdentityProviderOutboundSigner`. The example policy doesn't include `iam:DeleteWorkloadIdentityProviderOutboundSigner`.

## Step 1: Create a workload identity provider and template
<a name="wi-gs-step1"></a>

1. Open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).

1. In the navigation pane, choose **Agent and workload identity**.

1. Choose **Create a provider** to get started. In a management account or delegated administrator account, the button is **Create a provider for your organization**. If the account already has a provider, choose **Create provider**.

1. For **Name**, enter `payments-prod`.

1. For **Description**, enter `Sample provider for payments production workloads`.

1. Under **Identity format and scope**, keep the default **Scheme** and **Trust domain**. For **Scope**, choose **This account**. The console generates the trust domain `111122223333.aws.internal`, which this guide uses.

1. For **Templates**, choose **Customize templates**. On the **Amazon EKS** card, choose **Add**, and for **Name**, replace the generated name with `eks-prod-1`. Keep the default **Identity path** and **Attestation policy**.

1. Choose **Create provider and templates**.

IAM creates the provider with two JWT signing keys, so workloads can use JSON Web Token SPIFFE Verifiable Identity Documents (JWT-SVIDs) right away. For details and CLI steps, see [Create a workload identity provider](workload-identity-create-provider.md).

## Step 2: Check the IAM role's trust policy
<a name="wi-gs-step2"></a>

The role's trust policy doesn't need to change. AWS Security Token Service (AWS STS) adds the agent and workload identity to the session of the role that EKS Pod Identity already assumes.

Make sure that the trust policy of eks-pod-identity-role still has the statement that lets EKS Pod Identity assume the role:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ExistingPodIdentityTrust",
      "Effect": "Allow",
      "Principal": { "Service": "pods.eks.amazonaws.com" },
      "Action": ["sts:AssumeRole", "sts:TagSession"]
    }
  ]
}
```

**Keep this statement**  
If you remove it, pods that use this role stop receiving credentials.

To decide which workloads can reach a resource, name the identity in the resource's policy, as shown in Step 4. For more information, see Control access with agent and workload identity.

## Step 3: Turn on agent and workload identity for the workload
<a name="wi-gs-step3"></a>

1. Open the Amazon EKS console at [https://console.aws.amazon.com/eks/](https://console.aws.amazon.com/eks/).

1. Choose **prod-cluster-1**, and then choose the **Access** tab.

1. Under **Pod Identity associations**, choose the association for your workload, and then choose **Edit**.

1. Under **IAM for agents and workloads - preview**, turn on **Enable IAM for agents and workloads**. For **Provider**, choose **payments-prod**. For **Template**, choose **eks-prod-1**. If the console shows that your EKS Pod Identity Agent add-on is out of date, choose **Update version**.

1. Choose **Save changes**.

1. Restart the workload's pods so that they receive new credentials.

For more information, see Amazon EKS.

To do this with the AWS CLI instead, set the template and its provider on the association:

```bash
aws eks update-pod-identity-association \
  --cluster-name prod-cluster-1 \
  --association-id <association-id> \
  --workload-identity-config '{
    "enabled": true,
    "templateArn": "arn:aws:iam::111122223333:workload-identity-template/eks-prod-1",
    "providerArn": "arn:aws:iam::111122223333:workload-identity-provider/payments-prod"
  }'
```

The update must include both templateArn and providerArn. EKS rejects an update with only one of them.

## Step 4: Allow only this workload to read an S3 bucket
<a name="wi-gs-step4"></a>

In this step, you write a bucket policy that names the workload instead of the role. Then you confirm that the pod can read the bucket and that other workloads that use the same role can't.

### Add the bucket policy
<a name="wi-gs-step4-add-policy"></a>

1. Open the Amazon S3 console at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/).

1. Choose **amzn-s3-demo-bucket**, and then choose the **Permissions** tab.

1. Under **Bucket policy**, choose **Edit**.

1. Enter the following policy, and then choose **Save changes**.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowCheckoutWorkload",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
      "Condition": {
        "StringEquals": {
          "aws:PrincipalAccount": "111122223333",
          "aws:OriginIdentity/Subject": "spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa",
          "aws:OriginIdentity/Issuer": "arn:aws:iam::111122223333:workload-identity-provider/payments-prod"
        }
      }
    },
    {
      "Sid": "DenyOtherWorkloads",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
      "Condition": {
        "StringNotEquals": {
          "aws:OriginIdentity/Subject": "spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa"
        }
      }
    },
    {
      "Sid": "DenyOtherProviders",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
      "Condition": {
        "StringNotEquals": {
          "aws:OriginIdentity/Issuer": "arn:aws:iam::111122223333:workload-identity-provider/payments-prod"
        }
      }
    }
  ]
}
```

How the policy works:
+ `aws:OriginIdentity/Subject` matches the workload's identifier. AWS STS adds it to the role session when the pod gets credentials.
+ `aws:OriginIdentity/Issuer` matches your provider's ARN. An identifier is unique only within its provider, so always match both keys.
+ `aws:PrincipalAccount` limits the Allow statement to principals in your account. S3 Block Public Access treats a policy with `"Principal": "*"` as public unless a condition like this one limits it, and rejects the policy.
+ The two Deny statements make the bucket readable only by this workload. They deny s3:GetObject to every other principal, including administrators, so use a test bucket. You can still edit or delete the bucket policy.

The bucket and the role are in the same account, so the Allow statement is enough. The role doesn't need an S3 permission of its own. If the bucket is in a different account, the role's identity-based policy must also allow s3:GetObject.

### Test access
<a name="wi-gs-step4-test"></a>

1. From the pod, read the object:

   ```bash
   aws s3 cp s3://amzn-s3-demo-bucket/orders/hello.txt -
   ```

   The command prints the object's contents. The AWS CLI gets its credentials from EKS Pod Identity, as before. Because you turned on agent and workload identity in step 3, they're a role session for eks-pod-identity-role that carries these values:
   + `aws:OriginIdentity/Subject`: `spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa`
   + `aws:OriginIdentity/Issuer`: `arn:aws:iam::111122223333:workload-identity-provider/payments-prod`

   S3 evaluates the bucket policy against these values. Both match the Allow statement, and neither Deny statement applies, so the request succeeds.

1. From a pod of a different workload that uses the same role, for example service account reports-sa in namespace payments, run the same command. It fails with AccessDenied. That pod's identifier ends in /sa/reports-sa, so the DenyOtherWorkloads statement applies, even though both pods use the same IAM role. The same thing happens for a pod whose Pod Identity association doesn't have agent and workload identity turned on, because its session carries no agent and workload identity.

For more policy examples, see Control access with agent and workload identity.

## Step 5: Get a JWT to call a service outside AWS
<a name="wi-gs-step5"></a>

A JWT-SVID is a short-lived JSON Web Token whose subject is the workload's identifier. You choose its audience, so only the service that you name accepts it.

### Allow the role to request tokens and certificates
<a name="wi-gs-step5-allow"></a>

Add an inline policy to eks-pod-identity-role that lets a session get a JWT-SVID or an X.509 SPIFFE Verifiable Identity Document (X.509-SVID) only for its own identity. Run this from a computer where you have IAM permissions, not from the pod.

```bash
aws iam put-role-policy \
  --role-name eks-pod-identity-role \
  --policy-name workload-identity-credentials \
  --policy-document file://workload-identity-credentials.json
```

`workload-identity-credentials.json`:

```json
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["sts:GetWebIdentityToken", "sts:GetCertificate"],
    "Resource": "*",
    "Condition": {
      "StringEquals": {
        "aws:OriginIdentity/Subject": "spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa"
      }
    }
  }]
}
```

sts:GetWebIdentityToken and sts:GetCertificate don't support resource-level permissions, so Resource is \*. The `aws:OriginIdentity/Subject` condition limits the policy to the workload's own identity.

### Request a token
<a name="wi-gs-step5-request"></a>

From the pod, request a token and store it in a variable:

```bash
TOKEN=$(aws sts get-web-identity-token \
  --token-type JWT_SVID \
  --audience https://api.example.com \
  --signing-algorithm RS256 \
  --duration-seconds 900 \
  --query WebIdentityToken --output text)
```

The command prints nothing. The token is in TOKEN.

**Don't print or log a JWT-SVID**  
A JWT-SVID is a bearer credential. Any service that trusts your provider accepts it from whoever holds it, until it expires. Keep it out of terminal output, pod logs, and files.


| Parameter | Required | What it does | 
| --- | --- | --- | 
| `--token-type JWT_SVID` | Yes | Returns a JWT-SVID for the identity that the role session carries. `AWSIdentity` returns the existing outbound identity federation token for the role instead. | 
| `--audience` | Yes | Exactly one value for a JWT-SVID, which becomes the token's aud claim. Use the URL or identifier that the external service expects, so the token can't be replayed to a different service. | 
| `--signing-algorithm` | Yes | RS256 or ES384. Choose an algorithm that the external service accepts. Your provider has a key for each. | 
| `--duration-seconds` | No | 60–3,600 seconds. The default is 300. It can't be longer than the remaining role session, or the request fails with SessionDurationEscalation. | 
| `--query WebIdentityToken --output text` | No | Returns only the token, so that the shell can store it without printing it. | 

Unlike outbound identity federation tokens, JWT-SVIDs don't include custom claims from session tags.

To check the token, print its claims and nothing else:

```bash
payload=$(printf '%s' "$TOKEN" | cut -d. -f2 | tr '_-' '/+')
case $(( ${#payload} % 4 )) in 2) payload="$payload==" ;; 3) payload="$payload=" ;; esac
printf '%s' "$payload" | openssl base64 -d -A; echo
```

The output looks like this, formatted here for reading:

```json
{
  "iss": "https://wie-7f3a91c2e40b.workloads.tokens.sts.global.api.aws",
  "sub": "spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa",
  "aud": ["https://api.example.com"],
  "iat": 1796144400,
  "exp": 1796145300,
  "jti": "<unique token ID>"
}
```

A JWT-SVID contains only the sub, aud, iss, iat, exp, and jti claims. Every token has a unique jti, so a relying party can reject a token that it has already seen. The token's header has alg and kid, the ID of the signing key in your provider's JSON Web Key Set (JWKS). You can't add custom claims, and you can't use --scope or --subject-mode with --token-type JWT\_SVID.

Send the token to the external service, usually as a bearer token:

```bash
curl -H "Authorization: Bearer $TOKEN" https://api.example.com/orders
```

On Amazon EKS, an application can also get JWT-SVIDs from the EKS Pod Identity Agent through the Secure Production Identity Framework for Everyone (SPIFFE) Workload API. The Pod Identity Agent requests them with the RS256 algorithm and caches them for each audience. For a service that accepts each token only once, use get-web-identity-token as shown here. For more information, see Amazon EKS.

### Configure the external service to trust the token
<a name="wi-gs-step5-configure"></a>

The external service needs your provider's OpenID Connect (OIDC) issuer URL. Find it in the IAM console on the provider's Outbound signer page, under JWT signer, Token verifier information, or in the OidcIssuerUri field of `aws iam get-workload-identity-provider`. The service then does the following:

1. Fetches `<issuer>/.well-known/openid-configuration` and the JSON Web Key Set (JWKS) that it names, and caches them.

1. Checks the token's signature with the key that matches its kid, and checks iss, aud, and exp.

1. Authorizes the request based on sub, the workload's identifier.

The service doesn't call AWS for each request and doesn't need a shared secret. For more information, see Authenticate to services outside AWS.

## Step 6 (optional): Get an X.509 certificate for mutual TLS
<a name="wi-gs-step6"></a>

An X.509-SVID is a certificate whose URI subject alternative name (SAN) is the workload's identifier. Use it for mutual TLS (mTLS) with a service mesh or another service.

### Attach your CA to the provider
<a name="wi-gs-step6-attach"></a>

You do this once for each provider.

1. In the IAM console, open the payments-prod provider.

1. In the navigation pane, choose **Outbound signer**.

1. Under **Certificate signer**, choose **Enable**.

1. Choose **Choose from this account**, select your AWS Private CA, and then choose **Enable**.

Or use the AWS CLI:

```bash
aws iam create-workload-identity-provider-outbound-signer \
  --workload-identity-provider-arn arn:aws:iam::111122223333:workload-identity-provider/payments-prod \
  --outbound-signer 'X509={CertificateAuthorityId=<ca-id>,AccountId=111122223333}'
```

The CA starts signing about 1 hour after you attach it.

### Allow the role to use the CA
<a name="wi-gs-step6-allow-ca"></a>

AWS STS asks AWS Private CA to issue the certificate with the role's own session, so the role needs acm-pca:IssueCertificate and acm-pca:GetCertificate on the CA, even though the CA is in the same account. Add this statement to the workload-identity-credentials inline policy from step 5:

```json
{
  "Effect": "Allow",
  "Action": ["acm-pca:IssueCertificate", "acm-pca:GetCertificate"],
  "Resource": "arn:aws:acm-pca:*:111122223333:certificate-authority/<ca-id>",
  "Condition": { "Bool": { "aws:ViaAWSService": "true" } }
}
```

The `aws:ViaAWSService` condition means the role can use these permissions only through AWS STS, not by calling AWS Private CA directly.

### Request a certificate
<a name="wi-gs-step6-request"></a>

From the pod, create a key pair and a certificate signing request (CSR), and then request the certificate. The private key stays in the pod.

```bash
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
  -keyout svid.key -out svid.csr -subj "/CN=ignored"
aws sts get-certificate \
  --certificate-signing-request file://svid.csr \
  --max-duration-seconds 3600
```

```json
{
  "Certificate": "<PEM leaf certificate>",
  "CertificateChain": "<PEM certificate chain, which can include the root CA certificate>",
  "Subject": "spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa",
  "NotBefore": "2026-12-01T16:55:00Z",
  "NotAfter": "2026-12-01T17:55:00Z"
}
```

To save the certificate and check its identifier:

```bash
aws sts get-certificate --certificate-signing-request file://svid.csr \
  --query Certificate --output text > svid.pem
openssl x509 -in svid.pem -noout -ext subjectAltName
```

The output shows `URI:spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa`.

Keep these points in mind:
+ AWS STS ignores the subject and any SANs in the CSR. It takes the identifier from the role session.
+ Don't use CertificateChain as a source of trust anchors, because it can include the root CA certificate. Get trust anchors from your provider's trust bundle.
+ --max-duration-seconds is 3,600 through 43,200 seconds. The default is 43,200 (12 hours). Certificates can't be revoked, so use the shortest lifetime that works, and renew at half the lifetime.
+ The inline policy from step 5 allows sts:GetCertificate. The role also needs AWS Private CA permissions on the CA, as described before this list.
+ sts:GetCertificate is the AWS STS action that your workload calls. It's different from the AWS Private CA action acm-pca:GetCertificate, which AWS STS calls for you.

To use the certificate, configure the peer to trust the CA certificate from your provider's trust bundle and to authorize on the URI SAN. On Amazon EKS, the Pod Identity Agent can also request and renew certificates for you through the SPIFFE Workload API.

## Step 7: Find the workload in CloudTrail
<a name="wi-gs-step7"></a>

1. Complete steps 4 and 5, and optionally step 6, so that the pod has made calls with its identity.

1. Open the CloudTrail console at [https://console.aws.amazon.com/cloudtrail/](https://console.aws.amazon.com/cloudtrail/).

1. In the navigation pane, choose **Event history**.

1. Filter on **Event name** AssumeRole, and open the most recent event for eks-pod-identity-role.

1. Confirm that the event names your workload in `userIdentity.onBehalfOf`:
   + subject is the workload identifier, `spiffe://111122223333.aws.internal/us-east-1/eks/prod-cluster-1/ns/payments/sa/checkout-sa`.
   + issuer is your provider's ARN, `arn:aws:iam::111122223333:workload-identity-provider/payments-prod`.

Then look for the following related events:


| Event | Event source | What it shows | 
| --- | --- | --- | 
| GetObject | s3.amazonaws.com | The pod read the object in step 4, and S3 denied the other pod's request. S3 object reads are data events, so they appear only in a trail or event data store that logs S3 data events, not in Event history. | 
| GetWebIdentityToken | sts.amazonaws.com | The pod requested the JWT-SVID in step 5. | 
| GetCertificate | sts.amazonaws.com | The pod requested the X.509-SVID in step 6. AWS Private CA also records IssueCertificate and GetCertificate events in your account, because AWS STS calls it with the workload's role session. | 

For more information, see Logging and monitoring agent and workload identity.

## Clean up
<a name="wi-gs-cleanup"></a>

1. Remove the bucket policy from amzn-s3-demo-bucket, or delete the test bucket.

1. Delete the workload-identity-credentials inline policy from eks-pod-identity-role.

1. Turn off agent and workload identity on the Pod Identity association.

1. If you attached a CA in step 6, disable and then delete the outbound signer. If you created the CA only for this guide, delete it in AWS Private CA to stop its charges. For more information, see [Configure signing and the trust bundle](workload-identity-signing-trust-bundle.md).

1. Delete the template, and then the provider. For more information, see [Manage workload identity providers](workload-identity-manage-providers.md).

## Next steps
<a name="wi-gs-next-steps"></a>
+ [Admit only specific clusters or namespaces with attestation policies](workload-identity-attestation-policies.md)
+ Use agent and workload identity with AgentCore runtime and AgentCore Gateway
+ Learn more about JWT-SVIDs and X.509-SVIDs
+ [Set up a provider for your whole organization](workload-identity-create-provider.md)