Skip to content

Instantly share code, notes, and snippets.

@olih
Last active August 29, 2015 14:28
Show Gist options
  • Save olih/7df788a54353ffd96b54 to your computer and use it in GitHub Desktop.
Save olih/7df788a54353ffd96b54 to your computer and use it in GitHub Desktop.
install-aws.sh
#AWS
# . install-aws.sh
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
aws_session_token=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep Token | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
export AWS_ACCESS_KEY_ID=${aws_access_key_id}
export AWS_SECRET_ACCESS_KEY=${aws_secret_access_key}
export AWS_DEFAULT_REGION=eu-west-1
export AWS_SESSION_TOKEN=${aws_session_token}
alias awspass='echo "access: $AWS_ACCESS_KEY_ID secret: $AWS_SECRET_ACCESS_KEY region: $AWS_DEFAULT_REGION"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment