GitLab CI to AWS OIDC fails with `InvalidIdentityToken: Incorrect token audience`
IntermediateTroubleshootingCloud identity: IRSA, Workload Identity and CI OIDC
Answer
Likely causes → The aud in the job's id_tokens does not match any client ID on the IAM OIDC provider for gitlab.com (or your self-managed host).
Diagnose →
aws iam get-open-id-connect-provider --open-id-connect-provider-arn <arn> --query ClientIDList
Compare that list with the aud: in .gitlab-ci.yml.
Fix →
deploy:
id_tokens:
AWS_TOKEN:
aud: https://gitlab.com
script:
- >
aws sts assume-role-with-web-identity --role-arn "$ROLE_ARN"
--role-session-name "gl-$CI_JOB_ID" --web-identity-token "$AWS_TOKEN"
Make the provider's client ID list contain the same value.
Prevent → Restrict the trust policy on gitlab.com:sub (for example project_path:acme/api:ref_type:branch:ref:main) and keep the job template central.
More on Cloud identity: IRSA, Workload Identity and CI OIDC
A pod configured for IRSA runs `aws sts get-caller-identity` and gets the node role (`eks-node-group-role`) instead of its own roleBeginner`An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation: Not authorized to perform sts:AssumeRoleWithWebIdentity` from an IRSA podIntermediate`InvalidIdentityToken: No OpenIDConnect provider found in your account for https://oidc.eks.ap-south-1.amazonaws.com/id/ABC123`BeginnerIRSA env vars are present in the pod, but one legacy service still uses the node roleIntermediatePods without IRSA can still call AWS with the node's permissions through `169.254.169.254`IntermediateWith EKS Pod Identity, the pod gets `Unable to locate credentials` even though a pod identity association existsIntermediate