Aws notes/mfaenv.sh
From Federal Burro of Information
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