Skip to content

Instantly share code, notes, and snippets.

@maksim-paskal
Created September 7, 2023 09:52
Show Gist options
  • Save maksim-paskal/7f1759132dce4027d974d84a3b45d201 to your computer and use it in GitHub Desktop.
Save maksim-paskal/7f1759132dce4027d974d84a3b45d201 to your computer and use it in GitHub Desktop.
Get AWS tokens from mfa
#!/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