What is IMDSv2, and why enforce it?
AdvancedConceptAWS
Answer
The session-token version of the instance metadata service: a PUT for a token first, then requests that carry the token. It blocks SSRF attacks that steal instance role credentials through simple GETs.
TOKEN=$(curl -sX PUT http://169.254.169.254/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 300")