Created
March 25, 2019 23:17
-
-
Save ctgardner/340fcd2184e1dbc5c763c9d86c07745f to your computer and use it in GitHub Desktop.
Export AWS credentials of a role assumed via STS
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/bash | |
# usage: $ `aws sts assume-role --role-arn <arn> --role-session-name <session-name> | ./export_assumed_role.sh` | |
cat $1 | jq '.Credentials' | jq -r '.AccessKeyId, .SecretAccessKey, .SessionToken' | { | |
read -r access_key; | |
read -r secret_key; | |
read -r session_token; | |
echo "export AWS_ACCESS_KEY_ID=$access_key"; | |
echo "export AWS_SECRET_ACCESS_KEY=$secret_key"; | |
echo "export AWS_SESSION_TOKEN=$session_token"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment