Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2021 14:29
What would you like to do?
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# You must use 'source' to run this file, otherwise it has no effect
# Alternately, you can put it in .bashrc
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# e.g.
# $ source
# use this script to get the AWS temporary STS credentials from the
# Instance metadata sevice
# Note this key will expire after a few hours so you may need to rerun to get a new one
role_name=$( curl -s )
creds_json=$(curl -s${role_name})
export AWS_ACCESS_KEY_ID=$(echo "$creds_json" | jq .AccessKeyId |tr -d '"')
export AWS_SECRET_ACCESS_KEY=$(echo "$creds_json" | jq .SecretAccessKey| tr -d '"')
export AWS_SESSION_TOKEN=$(echo "$creds_json" | jq .Token|tr -d '"')
export AWS_DEFAULT_REGION=eu-west-1
export SERVICE_REGION=$AWS_DEFAULT_REGION # used by python ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment