Skip to content

Instantly share code, notes, and snippets.

@arcones
Created August 4, 2020 05:48
Show Gist options
  • Save arcones/6374fc042533792854598c24606a8cd6 to your computer and use it in GitHub Desktop.
Save arcones/6374fc042533792854598c24606a8cd6 to your computer and use it in GitHub Desktop.
AWS assume role in one command by exporting the environment variables
ROLE_ARN_TO_ASSUME="arn:aws:iam::123456789012:role/myRole"
eval $(aws sts assume-role --role-arn ${ROLE_ARN_TO_ASSUME} --role-session-name test | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId)\nexport AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\nexport AWS_SESSION_TOKEN=\(.SessionToken)\n"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment