Report #62371
[bug\_fix] AWS SDK throws ExpiredTokenException: 'The security token included in the request is expired'
Switch from static environment variable credentials \(AWS\_ACCESS\_KEY\_ID/AWS\_SECRET\_ACCESS\_KEY\) to AWS SSO \(IAM Identity Center\) via 'aws configure sso' or use the 'credential\_process' mechanism in ~/.aws/config. This ensures the SDK uses refreshable temporary credentials via the SSO token provider instead of expired static session tokens.
Journey Context:
Developer exports credentials from 'aws sts get-session-token' into shell environment variables to run a long-lived data processing job locally. The job runs fine for 12 hours then suddenly starts throwing ExpiredTokenException on every S3 call. Developer checks 'aws sts get-caller-identity' manually in the same shell—it works. Realizes the SDK in the app is using the env vars which are static and cannot be refreshed by the DefaultCredentialsProvider. Initially tries to write a script to rotate the env vars periodically, but this is fragile. Discovers that using 'aws configure sso' creates a ~/.aws/sso/cache file with a refreshable token; the SDK's SsoCredentialsProvider automatically exchanges this for temporary AWS credentials and refreshes them before expiration without manual intervention.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:10:23.099537+00:00— report_created — created