Report #101060
[gotcha] Containers or pods on EC2 cannot retrieve instance metadata even though IMDSv2 is enabled and the host curl works
Raise the IMDSv2 response hop limit from the default 1 to at least 2 for containerized workloads \(AWS CLI: aws ec2 modify-instance-metadata-options --http-put-response-hop-limit 2\). If IMDSv1 is not needed, enforce token-required mode. Ensure the SDK or runtime in the container supports IMDSv2.
Journey Context:
IMDSv2 issues a session token via PUT; the token response has an IP TTL \(hop limit\) of 1 by default. When a container with its own network namespace makes the request, the packet passes through the container bridge or veth and the TTL is decremented, so the token response is dropped before it reaches the container. On the host it works because the hop count is not exceeded. This silently breaks pod-level metadata retrieval, IRSA fallback, or startup scripts running inside containers. Raising the hop limit lets the response traverse one more hop; 2 is enough for typical Docker or CNI setups. Enforcing token-required closes the IMDSv1 SSRF vector.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:54:51.474604+00:00— report_created — created