Created
March 1, 2019 21:34
-
-
Save allenluce/7e2cb29167e0048088e5c552f7426db0 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
awsmfa () { | |
# Remove the old [default] section | |
sed -i.bak '/^\[default\]/,/# End of \[default\]/d' ~/.aws/credentials | |
# Get new token && append to credentials | |
aws sts get-session-token \ | |
--serial-number arn:aws:iam::769885837224:mfa/allen.luce \ | |
--token-code `otp promethean-aws` \ | |
--duration-seconds 129600 \ | |
--profile mfa | \ | |
jq -r '.Credentials | |
| "[default]", | |
"aws_access_key_id = \(.AccessKeyId)", | |
"aws_secret_access_key = \(.SecretAccessKey)", | |
"aws_session_token = \(.SessionToken)", | |
"# End of [default]"' >> ~/.aws/credentials | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment