Interview Prep/AWS/ECS, EKS, ECR and Lambda

A pod's S3 calls fail with `AccessDenied ... User: arn:aws:sts::111111111111:assumed-role/eks-node-role/i-0abc is not authorized`. Why is it using the node role?

AdvancedTroubleshootingECS, EKS, ECR and Lambda
Answer

Likely causes → The pod has no working IRSA or Pod Identity setup, so the SDK falls back to the node's instance profile through IMDS. Common reasons: the service account has no eks.amazonaws.com/role-arn annotation (IRSA), or no Pod Identity association exists, or the Pod Identity Agent add-on is missing, or the pod was created before the association and was never restarted. An old SDK that does not support the credential source does the same.

Diagnose →

kubectl get sa app -n prod -o yaml | grep -A2 annotations
aws eks list-pod-identity-associations --cluster-name prod --namespace prod
kubectl exec -n prod deploy/app -- env | grep -E 'AWS_ROLE_ARN|AWS_WEB_IDENTITY|AWS_CONTAINER_CREDENTIALS_FULL_URI'
kubectl get ds -n kube-system eks-pod-identity-agent

Fix →

  1. Pod Identity: install the add-on, then run aws eks create-pod-identity-association --cluster-name prod --namespace prod --service-account app --role-arn <role>. The role trust policy allows pods.eks.amazonaws.com with sts:AssumeRole and sts:TagSession
  2. Restart the pods so the credentials get injected

Prevent → Block pod access to IMDS (set the hop limit to 1 on nodes) so a missing setup fails loudly instead of quietly using node permissions.

aws All AWS questions Roadmap: EKS, ECS & serverless on AWS

More on ECS, EKS, ECR and Lambda