Skip to content

Instantly share code, notes, and snippets.

@pkqk
Created July 2, 2024 04:14
Show Gist options
  • Save pkqk/7ce9a6a7808604f2a32f5f70f555b2ba to your computer and use it in GitHub Desktop.
Save pkqk/7ce9a6a7808604f2a32f5f70f555b2ba to your computer and use it in GitHub Desktop.
AWS IMDSv2 function
function imds () {
local u="$1"
shift
curl -w "\n" -H "X-aws-ec2-metadata-token: $(curl -s -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" "http://169.254.169.254/latest/api/token")" "http://169.254.169.254/${u}" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment