Created
September 8, 2021 06:15
-
-
Save uguisu-an/6f89cbfd7f5f9be6d73580fe57fbb1e6 to your computer and use it in GitHub Desktop.
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
if [ $# -ne 3 ]; then | |
echo "usage: aws-session {profile} {serial-number} {token-code}" | |
exit 1 | |
fi | |
unset AWS_ACCESS_KEY_ID | |
unset AWS_SECRET_ACCESS_KEY | |
unset AWS_SESSION_TOKEN | |
export $(aws sts get-session-token --profile $1 --serial-number $2 --token-code $3 | jq -r '.Credentials | "AWS_ACCESS_KEY_ID=\(.AccessKeyId)", "AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)", "AWS_SESSION_TOKEN=\(.SessionToken)"') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment