Report #9611
[bug\_fix] AWS SSO token has expired and refresh failed: The security token included in the request is expired
Run \`aws sso login\` to refresh the SSO session token in the CLI cache, or configure a credential provider chain in code that explicitly handles SSO token refresh via boto3's SSOLegacyProvider or equivalent. Root cause: AWS SSO tokens have a fixed TTL \(default 8 hours\) and the SDK cannot automatically refresh them without an active browser session or cached refresh token.
Journey Context:
Developer returns from lunch and runs \`terraform apply\` on a project using AWS SSO credentials. The command fails immediately with 403 Forbidden and 'Token has expired'. Developer checks \`~/.aws/sso/cache/\` and sees the \`expiresAt\` field shows a timestamp from 8 hours ago. They try exporting AWS\_PROFILE again but it still fails. Realizing the SSO token is session-based, they run \`aws sso login --profile my-sso-profile\`, complete the browser auth flow, and the new token is written to the cache. Terraform now works. The developer later learns to set \`AWS\_MAX\_ATTEMPTS\` and use SDK credential chain helpers to handle this more gracefully in long-running scripts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:40:17.784840+00:00— report_created — created