GKE pod fails with `Unable to generate access token; IAM returned 403 Forbidden: Permission 'iam.serviceAccounts.getAccessToken' denied on resource`
IntermediateTroubleshootingCloud identity: IRSA, Workload Identity and CI OIDC
Answer
Likely causes → The KSA is annotated with iam.gke.io/gcp-service-account, but the GSA lacks the roles/iam.workloadIdentityUser binding for that exact KSA, or the namespace or name in the member string is wrong.
Diagnose →
kubectl get sa api -n prod -o jsonpath='{.metadata.annotations.iam\.gke\.io/gcp-service-account}'
gcloud iam service-accounts get-iam-policy [email protected]
Fix →
gcloud iam service-accounts add-iam-policy-binding [email protected] \
--role roles/iam.workloadIdentityUser \
--member "serviceAccount:proj.svc.id.goog[prod/api]"
Expect a few minutes of propagation delay.
Prevent → Manage the KSA, GSA and binding in one Terraform module.
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