Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Last active February 6, 2020 03:49
Show Gist options
  • Save KyMidd/2941e6220ccb22443b3254e5cbb8bb60 to your computer and use it in GitHub Desktop.
Save KyMidd/2941e6220ccb22443b3254e5cbb8bb60 to your computer and use it in GitHub Desktop.
# Clean variables
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
unset AWS_SESSION_TOKEN
unset ACCOUNT_ID
# Call for ACCOUNT_ID
curl -s http://169.254.169.254/latest/meta-data/identity-credentials/ec2/info | jq -r '.AccountId' | awk '{print "export", "ACCOUNT_ID="$0}' > variables
# Call for INSTANCE_ID
curl -s http://169.254.169.254/latest/meta-data/instance-id | awk '{print "export", "INSTANCE_ID="$0}' >> variables
# Read account ID variables into global
. ./variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment