Created
July 22, 2019 21:24
-
-
Save pwillis-els/aff9d0cd9bd32b396355aecb280d85e3 to your computer and use it in GitHub Desktop.
Get IAM access key from AWS EC2 instance profile metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
AWS_INST_PROFILE=$(curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/ | tail) | |
curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/${AWS_INST_PROFILE} \ | |
| python -c 'import sys,json;j=json.load(sys.stdin);print("AWS_ACCESS_KEY_ID=%s\nAWS_SECRET_ACCESS_KEY=%s\n" % (j["AccessKeyId"],j["SecretAccessKey"]))' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment