Difference between revisions of "Aws notes/mfaenv.sh"

From Federal Burro of Information
Jump to navigationJump to search
(Created page with "<pre> #!/bin/sh unset AWS_ACCESS_KEY_ID unset AWS_SECRET_ACCESS_KEY unset AWS_SESSION_TOKEN DURATION=1800 source ~/aws.env echo enter code read -s code IN=$(aws sts get-ses...")
 
(No difference)

Latest revision as of 17:43, 8 July 2019

#!/bin/sh

unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
unset AWS_SESSION_TOKEN

DURATION=1800

source ~/aws.env
echo enter code
read -s code
IN=$(aws sts get-session-token --serial-number "MFA ARN" --duration-seconds $DURATION --query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' --output text --token-code $code)
read -r access secret token <<< "$IN"
export AWS_ACCESS_KEY_ID=$access
export AWS_SECRET_ACCESS_KEY=$secret
export AWS_SESSION_TOKEN=$token