Interview Prep/Real-World Interview/Cloud provider issues

Scripts and Terraform runs fail on your laptop with "ExpiredToken: The security token included in the request is expired."

BeginnerTroubleshootingCloud provider issues
Answer

Likely causes → Temporary credentials (from IAM Identity Center/SSO, assume-role, or MFA sessions) have a fixed lifetime and have expired. Old exported AWS_SESSION_TOKEN variables in the shell override a fresh profile.

Diagnose →

aws sts get-caller-identity
env | grep ^AWS_
aws configure list

Fix → Refresh the session (aws sso login --profile prod) and unset stale environment variables (unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN).

Prevent → Use named SSO profiles with automatic refresh, set a role session duration that fits the work, and never paste long-lived keys into shells or CI.

All Real-World Interview questions Roadmap: Interview readiness

More on Cloud provider issues