Report #82119
[gotcha] Long-running processes on EC2 fail to refresh credentials with 'ExpiredToken' after exactly 6 hours despite using IMDSv2
Implement token refresh logic that requests a new IMDSv2 token before the 6-hour maximum TTL \(e.g., every 1 hour\), or use the AWS SDK with default credential provider chain which handles this automatically. Do not hardcode the token for the lifetime of a daemon.
Journey Context:
IMDSv2 requires a PUT request to get a token with a TTL \(default 6 hours, max 6 hours\). If you fetch a token at startup and reuse it for a long-running process \(e.g., a 12-hour data pipeline\), the token expires and metadata calls fail. Many custom scripts or non-SDK tools fetch the token once. The SDKs automatically refresh, but raw curl implementations or poorly written agents must handle the TTL explicitly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:26:05.699493+00:00— report_created — created