Aws notes/mfaenv.sh

From Federal Burro of Information
Revision as of 17:43, 8 July 2019 by David (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
#!/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