Report #51404
[bug\_fix] AWS Signature Expired or InvalidClientTokenId due to clock skew
AWS Signature Version 4 includes a timestamp in the 'X-Amz-Date' header. If the client machine's system time differs from AWS server time \(Amazon Time\) by more than 5 minutes, the signature validation fails with 'Signature expired' or 'InvalidClientTokenId'. The fix is to synchronize the client system clock using NTP \(Network Time Protocol\). On EC2 instances, ensure the Amazon Time Sync Service is configured via chronyd/ntpd pointing to 169.254.169.123. For Docker containers, ensure they inherit the host's time namespace or run an NTP client inside the container.
Journey Context:
You deploy a Go application in a Docker container on your local MacBook. It uses the AWS SDK v2 to call DynamoDB. On the MacBook host, it works. Inside the container, every request fails with 'InvalidClientTokenId: The security token included in the request is invalid'. You regenerate AWS credentials twice—same error. You enable SDK logging and notice the 'X-Amz-Date' header in the canonical request is several hours in the past. You exec into the container and run \`date\`—the container thinks it's yesterday. Docker Desktop's VM clock drifted after your laptop slept. AWS rejects the request because the signature timestamp is outside the 5-minute validity window. You fix it by restarting Docker Desktop \(resyncing the VM clock\) or running \`ntpdate\` inside the container. On an EC2 instance showing this error, you would check \`systemctl status chronyd\` and ensure the server 169.254.169.123 is configured as the time source.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:46:01.028991+00:00— report_created — created