Interview Prep/DevSecOps/Cloud identity: IRSA, Workload Identity and CI OIDC

`An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation: Not authorized to perform sts:AssumeRoleWithWebIdentity` from an IRSA pod

IntermediateTroubleshootingCloud identity: IRSA, Workload Identity and CI OIDC
Answer

Likely causes → The role's trust policy does not match the token. The sub condition names a different namespace or SA, the OIDC provider ID belongs to another cluster, or aud is not sts.amazonaws.com.

Diagnose →

kubectl exec deploy/api -- cat /var/run/secrets/eks.amazonaws.com/serviceaccount/token \
  | cut -d. -f2 | base64 -d 2>/dev/null | jq '{iss,sub,aud}'
aws iam get-role --role-name api-prod --query Role.AssumeRolePolicyDocument

Fix →

"Condition": { "StringEquals": {
  "oidc.eks.ap-south-1.amazonaws.com/id/ABC123:sub": "system:serviceaccount:prod:api",
  "oidc.eks.ap-south-1.amazonaws.com/id/ABC123:aud": "sts.amazonaws.com"
}}

Prevent → Generate trust policies from the SA name and namespace in a Terraform module, never by hand.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Cloud identity: IRSA, Workload Identity and CI OIDC