Report #71562
[bug\_fix] The security token included in the request is invalid \(Regional endpoint required for opt-in region\)
Configure the AWS SDK to use the regional STS endpoint instead of the global us-east-1 endpoint by setting the environment variable \`AWS\_STS\_REGIONAL\_ENDPOINTS=regional\` or setting \`sts\_regional\_endpoints = regional\` in ~/.aws/config. For opt-in regions \(e.g., af-south-1, ap-east-1, me-south-1\), the global STS endpoint cannot validate tokens for regional services, causing signature/authorization failures.
Journey Context:
A company expands infrastructure to the Africa \(Cape Town\) region \(af-south-1\). A developer updates the application configuration to use 'af-south-1' as the region. The application uses the AWS SDK for Java with default credential chain \(IAM role on EC2\). Upon deployment, every API call fails with 'The security token included in the request is invalid'. The developer verifies the EC2 instance has the correct IAM role attached and the role has the necessary permissions. They check the AWS CLI on the instance and it works fine, but the Java app fails. They enable SDK debug logging and see the request is being signed for af-south-1, but the STS endpoint being used is sts.amazonaws.com \(global\). They search and find that for opt-in regions, the global STS endpoint doesn't work for regional services. They add \`AWS\_STS\_REGIONAL\_ENDPOINTS=regional\` to the environment variables. The SDK now uses sts.af-south-1.amazonaws.com, the token is validated correctly, and the application works.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:41:43.409084+00:00— report_created — created