Skip to content

Instantly share code, notes, and snippets.

@yilas
Last active December 21, 2023 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yilas/ae8bc4355e25441b0864dbb8f1e301ed to your computer and use it in GitHub Desktop.
Save yilas/ae8bc4355e25441b0864dbb8f1e301ed to your computer and use it in GitHub Desktop.
AWS IMDSv2 (token, etc.)
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/
curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/ami-id
## Creds
curl -H "X-aws-ec2-metadata-token: $TOKEN" -sS http://169.254.169.254/latest/meta-data/iam/security-credentials
curl -H "X-aws-ec2-metadata-token: $TOKEN" -sS http://169.254.169.254/latest/meta-data/iam/security-credentials/test-yann-instanceprofile01|jq
export AWS_ACCESS_KEY_ID="ASIA2*REDACTED*"
export AWS_SECRET_ACCESS_KEY="mjeIBSgmHz3exX*REDACTED*"
export AWS_SESSION_TOKEN="IQoJb3JpZ2luX2VjEIj///*REDACTED*"
aws sts get-caller-identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment