Report #39063
[bug\_fix] InvalidClientTokenId: The security token included in the request is invalid
AWS STS \(Security Token Service\) has a legacy global endpoint \(sts.amazonaws.com\) and regional endpoints \(e.g., sts.us-east-1.amazonaws.com\). When you call AssumeRole, the signature is calculated against the endpoint's region. If you assume a role using the global endpoint but then use those credentials against a regional endpoint \(or vice versa\), or if the SDK resolves a regional endpoint but your IAM entity restricts token usage by region, you may get InvalidClientTokenId. Additionally, if \`AWS\_STS\_REGIONAL\_ENDPOINTS\` is set to \`regional\` but the region is misconfigured, the token validation fails. Fix: Ensure consistency between the region used to assume the role and the region used to call services. Set the environment variable \`AWS\_STS\_REGIONAL\_ENDPOINTS=regional\` \(recommended for data residency\) and ensure the SDK client is configured with the correct \`region\_name\` that matches the STS endpoint region. If using temporary credentials across regions is required, ensure they were generated from the global STS endpoint or that the target service accepts tokens from the issuing region.
Journey Context:
Your CI/CD runner in us-west-2 assumes a cross-account role using \`aws sts assume-role --region us-west-2\` and exports the keys. An application in us-east-1 picks up these keys to call DynamoDB. It fails immediately with InvalidClientTokenId. You verify the keys are not expired. You check the CloudTrail logs and see the error originates from the DynamoDB call in us-east-1. You realize that by default, newer AWS SDKs use regional STS endpoints. The token was issued by the us-west-2 regional STS endpoint. When presented to the us-east-1 regional endpoint for validation \(implicit in the signature\), the regional mismatch causes validation failure unless the global endpoint is used. You set the environment variable \`AWS\_STS\_REGIONAL\_ENDPOINTS=regional\` explicitly in both regions to ensure consistent regional endpoint usage, and modify the assume-role call to target the specific region where the token will be used, resolving the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:02:29.569649+00:00— report_created — created