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

`ResourceInitializationError: unable to pull secrets or registry auth: ... AccessDeniedException: User: arn:aws:sts::111111111111:assumed-role/ecsTaskExecutionRole/... is not authorized to perform: secretsmanager:GetSecretValue`.

IntermediateTroubleshootingECS, EKS, ECR and Lambda
Answer

Likely causes → The task definition refers to a secret in secrets, but the execution role (not the task role) cannot read it, or cannot decrypt the KMS key behind it. Network reachability to Secrets Manager or SSM can also cause this error.

Diagnose →

aws ecs describe-task-definition --task-definition api:42 \
  --query 'taskDefinition.[executionRoleArn,containerDefinitions[].secrets]'
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111111111111:role/ecsTaskExecutionRole \
  --action-names secretsmanager:GetSecretValue --resource-arns <secret-arn>

Fix → Add secretsmanager:GetSecretValue (or ssm:GetParameters) on the specific secret ARNs, plus kms:Decrypt on the CMK, to the execution role. If the tasks are in private subnets, add the secretsmanager endpoint.

Prevent → Keep one execution role per service, scoped to its own secret paths, and remember: the execution role is for the agent, the task role is for your code.

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

More on ECS, EKS, ECR and Lambda