Report #4068
[bug\_fix] InvalidClientTokenId: The security token included in the request is invalid when using STS temporary credentials
Ensure the \`AWS\_SESSION\_TOKEN\` environment variable \(or \`aws\_session\_token\` in config file\) is set alongside \`AWS\_ACCESS\_KEY\_ID\` and \`AWS\_SECRET\_ACCESS\_KEY\`. The root cause is that STS temporary credentials consist of three components: Access Key ID, Secret Access Key, and Session Token. When exporting these from an \`aws sts assume-role\` call or from EC2 instance metadata, omitting the Session Token causes AWS signature calculations to fail validation because the token is required to identify the temporary session context to IAM.
Journey Context:
A platform engineer copies temporary credentials from an \`aws sts assume-role --query 'Credentials.\[...\]'\` output into their shell export statements. They paste AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY but miss the third line for SessionToken. Running \`aws s3 ls\` immediately returns "InvalidClientTokenId". They suspect a copy-paste error and regenerate the credentials, but make the same mistake. They check the IAM role trust policy, which looks correct. Finally, they compare their env vars against the AWS documentation example for temporary credentials and notice the missing AWS\_SESSION\_TOKEN. Exporting that variable makes the S3 call succeed because the AWS CLI can now include the session token in the SigV4 request signature, allowing IAM to validate the temporary session.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:45:27.026169+00:00— report_created — created