Skip to content

Instantly share code, notes, and snippets.

@chrisns
Last active June 28, 2019 13:23
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 chrisns/4b732c4b2f85272aef6706d43e7063f8 to your computer and use it in GitHub Desktop.
Save chrisns/4b732c4b2f85272aef6706d43e7063f8 to your computer and use it in GitHub Desktop.
get iam creds from metadata service
const http = require('http'); http.get("http://169.254.169.254/latest/meta-data/iam/security-credentials/", res => res.on("data", role => http.get(`http://169.254.169.254/latest/meta-data/iam/security-credentials/${role}`, res => res.on("data", (data, json=JSON.parse(data)) => console.log(`export AWS_ACCESS_KEY_ID=${json.AccessKeyId} AWS_SECRET_ACCESS_KEY=${json.SecretAccessKey} AWS_SESSION_TOKEN=${json.Token}`)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment