Interview Prep/AWS/IAM and Access Errors

Instance role credentials stopped working inside a container on an EC2 host: `Unable to locate credentials`.

IntermediateTroubleshootingIAM and Access Errors
Answer

Likely causes → IMDSv2 hop limit of 1 blocks containers from reaching metadata.

Diagnose →

curl -s -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60'
aws ec2 describe-instances --instance-ids i-0abc --query 'Reservations[].Instances[].MetadataOptions'

Fix →

  1. Set hop limit to 2: aws ec2 modify-instance-metadata-options --instance-id i-0abc --http-put-response-hop-limit 2 --http-tokens required
  2. Or use task or pod roles

Prevent → Bake hop limit into launch templates.

aws All AWS questions Roadmap: AWS core services

More on IAM and Access Errors