Interview Prep/Terraform/Authentication and Cloud API Errors

`Error: No valid credential sources found` followed by `no EC2 IMDS role found ... context deadline exceeded`.

BeginnerTroubleshootingAuthentication and Cloud API Errors
Answer

Likely causes → No credentials in env vars, no profile, no SSO session; the provider fell back to the EC2 metadata service, which doesn't exist on your laptop or runner.

Diagnose →

env | grep -E '^AWS_(PROFILE|ACCESS_KEY_ID|REGION|ROLE_ARN|WEB_IDENTITY)'
aws sts get-caller-identity

Fix → export AWS_PROFILE=prod-admin && aws sso login, or in CI configure OIDC credentials before Terraform runs.

Prevent → Print aws sts get-caller-identity as the first step of every pipeline.

All Terraform questions

More on Authentication and Cloud API Errors