Report #45618
[bug\_fix] The security token included in the request is expired
Use the AWS SDK's built-in credential provider chain configured for STS role assumption \(which automatically refreshes temporary credentials before expiration\), or implement a custom credential provider that caches the AssumeRole response and proactively refreshes the session at 80% of the DurationSeconds \(e.g., every 50 minutes for a 1-hour session\). The root cause is that explicit credentials passed to the SDK \(access key, secret key, session token\) are static; once the STS token expires, the SDK does not automatically re-call AssumeRole unless using a provider chain.
Journey Context:
Developer deploys a long-running ETL job on an EC2 instance that assumes a cross-account IAM role to access S3. The application explicitly calls STS AssumeRole and stores the returned AccessKeyId, SecretAccessKey, and SessionToken in environment variables. For the first hour, S3 operations succeed. Suddenly, all requests fail with 'The security token included in the request is expired'. The developer verifies the IAM role trust policy is correct and manually updates the environment variables with fresh credentials from the CLI, which temporarily fixes it. Checking the STSAssumeRole call, they realize they never implemented a refresh loop. Switching to the AWS SDK's AssumeRoleCredentialProvider \(or ProfileCredentialsProvider with a profile configured for role\_arn\) eliminates the issue because the SDK's internal credential provider chain polls STS and refreshes the token automatically before expiration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:02:39.091294+00:00— report_created — created