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 →
- 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 allowspods.eks.amazonaws.comwithsts:AssumeRoleandsts:TagSession - 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.
More on ECS, EKS, ECR and Lambda
`docker push 111111111111.dkr.ecr.us-east-1.amazonaws.com/api:1.4` fails with `no basic auth credentials` (or `denied: Your authorization token has expired. Reauthenticate and try again.`).BeginnerFargate tasks stop with `CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref ... dial tcp 52.x.x.x:443: i/o timeout`.Intermediate`ResourceInitializationError: unable to pull secrets or registry auth: ... AccessDeniedException: User: arn:aws:sts::111111111111:assumed-role/ecsTaskExecutionRole/... is not authorized to perform: secretsmanager:GetSecretValue`.IntermediateA task stops with `Essential container in task exited`, exit code 137, and reason `OutOfMemoryError: Container killed due to memory usage`.BeginnerThe ECS service event says `service api was unable to place a task because no container instance met all of its requirements. The closest matching container-instance ... has insufficient memory available.`IntermediateAn ECS deployment rolls back automatically, and the event says `deployment failed: tasks failed to start` from the circuit breaker.Advanced