AWS006 - AWS Refused the Agent's Web Identity
Agent error code #AWS006 indicates that the integration uses the agent's own AWS identity, the agent found a web identity token (EKS IRSA), and AWS refused to exchange it for the role. The token was presented, so this is not #AWS005 (no identity at all). It is also not a permissions problem on the role (#AWS002): AWS never got as far as the role's EC2 policy.
AWS reports this as AccessDenied, InvalidIdentityToken or ExpiredTokenException on the AssumeRoleWithWebIdentity call, which is worth knowing if you are correlating against CloudTrail.
Common causes include:
- The role's trust policy names a different namespace or service account from the one the agent's pod runs as
- The trust policy names the wrong OIDC provider, or the cluster's OIDC provider is not registered in IAM
- The trust policy's
audcondition is notsts.amazonaws.com - The projected service account token has expired and the kubelet stopped refreshing it
Steps to Resolve
Check the Trust Policy
- In the AWS console, go to IAM > Roles and open the role named in the agent pod's
eks.amazonaws.com/role-arnannotation - Open Trust relationships
- Confirm the
Federatedprincipal is the cluster's OIDC provider (oidc.eks.<region>.amazonaws.com/id/<id>) - Confirm the
subcondition issystem:serviceaccount:<namespace>:<service account>for the agent's pod, andaudissts.amazonaws.com
Confirm the OIDC Provider Exists
- Run
aws eks describe-cluster --name <cluster> --query cluster.identity.oidc.issuerto get the issuer URL - In IAM > Identity providers, confirm a provider with that URL is listed. If it is not, create it
Verify From the Agent Pod
kubectl exec -n <namespace> <agent pod> -- aws sts get-caller-identity
A working setup prints the role's ARN. An AssumeRoleWithWebIdentity error is this fault, and its message says which check failed.