Created
July 2, 2018 13:20
-
-
Save ben-bourdin451/b4894438d4d4de8012f3c7ab5b75d8a8 to your computer and use it in GitHub Desktop.
Bash script to refresh session tokens for assuming roles that require MFA
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 | |
read -p 'MFA Token: ' mfavar | |
line=$(aws sts get-session-token --profile $AWS_IDENTITY_ACCOUNT --serial-number $MFA_SERIAL --token-code $mfavar --output text) | |
echo $line | awk 'BEGIN {FS=" "}; {printf("[default]\naws_access_key_id=%s\naws_secret_access_key=%s\naws_session_token=%s\n#expiry %s",$2,$4,$5,$3)}' > ~/.aws/credentials |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment