Created
April 29, 2020 13:24
-
-
Save lacerdaeduardo/b079266e5e07caf11c009f12835f6780 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
PROFILE=profile | |
MFA_SERIAL=xxx | |
USER=xxx | |
RESULT=$(aws sts get-session-token --serial-number arn:aws:iam::${MFA_SERIAL}:mfa/${USER} --token-code $1 --profile ${PROFILE}) | |
ACCESS_KEY_ID="$(echo $RESULT | jq '.Credentials.AccessKeyId' -r)" | |
SECRET_KEY=$(echo $RESULT | jq '.Credentials.SecretAccessKey' -r) | |
TOKEN=$(echo $RESULT | jq '.Credentials.SessionToken' -r) | |
aws configure set aws_access_key_id $ACCESS_KEY_ID | |
aws configure set aws_secret_access_key $SECRET_KEY | |
aws configure set aws_session_token $TOKEN | |
echo "CREDENTIALS SET.......... " | |
echo "ENV - DEV " | |
echo "ACCESS_KEY: $ACCESS_KEY_ID" | |
echo "SECRET: $SECRET_KEY" | |
echo "TOKEN: $TOKEN" | |
echo ".........................." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to run this file:
brew install jq
chmod 755 ./set-awscli-keys-and-token.sh
call the script:
./set-awscli-keys-and-token.sh **<TOKEN>**