Created
September 7, 2023 09:52
-
-
Save maksim-paskal/7f1759132dce4027d974d84a3b45d201 to your computer and use it in GitHub Desktop.
Get AWS tokens from 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/sh | |
auth=$(aws sts get-session-token --profile prod-static \ | |
--serial-number arn:aws:iam::<mfa> \ | |
--duration-seconds 129600 \ | |
--token-code "$1") | |
aws --profile prod configure set region us-east-1 | |
aws --profile prod configure set aws_access_key_id "$(echo $auth | jq -r .Credentials.AccessKeyId)" | |
aws --profile prod configure set aws_secret_access_key "$(echo $auth | jq -r .Credentials.SecretAccessKey)" | |
aws --profile prod configure set aws_session_token "$(echo $auth | jq -r .Credentials.SessionToken)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment