`ExpiredToken: The security token included in the request is expired` in a long CI job. How do you fix it?
BeginnerTroubleshootingIAM and Access Errors
Answer
Likely causes → Assumed-role sessions last 1 hour by default and the job exceeded it, or cached credentials are stale.
Diagnose →
aws sts get-caller-identity
env | grep AWS_
aws iam get-role --role-name ci-deploy --query Role.MaxSessionDuration
Fix →
- Raise role
MaxSessionDurationand request--duration-secondsaccordingly - Re-authenticate mid-job or split the job
- Unset stale
AWS_SESSION_TOKENvariables left over from a prior step
Prevent → Use OIDC with fresh credentials per job and keep jobs short.
More on IAM and Access Errors
`An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied` for a user who has S3 read access. What is wrong?Beginner`User: arn:aws:sts::111111111111:assumed-role/dev/bob is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::222222222222:role/deploy`. Why?Intermediate`An error occurred (AccessDenied) ... because no identity-based policy allows the s3:GetObject action` yet a bucket policy allows the user. Cross-account?IntermediateIAM policy validation: `MalformedPolicyDocument: Policy document should not specify a principal`. What happened?Intermediate`The security token included in the request is invalid` when using `aws` CLI.BeginnerSSO login works in the browser but `aws sso login` hangs or gives `Error loading SSO Token: Token for ... does not exist`.Intermediate