Created
August 4, 2019 11:00
-
-
Save jcaxmacher/1701c7e6e23d05f7d3023dd940304cce to your computer and use it in GitHub Desktop.
Get AWS Assumed-Role Credentials in a Windows-Environment-Variable-friendly format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM %1 - AWS credential profile for the AssumRole API call | |
REM %2 - The ARN of the role to assume | |
REM %3 - The name of the newly created role session | |
aws --profile %1 sts assume-role --role-arn %2 --role-session-name %3 | python -c "import sys,json;data=sys.stdin.read();creds=json.loads(data);print(f'set AWS_ACCESS_KEY_ID={creds[""Credentials""][""AccessKeyId""]}');print(f'set AWS_SECRET_ACCESS_KEY={creds[""Credentials""][""SecretAccessKey""]}');print(f'set AWS_SESSION_TOKEN={creds[""Credentials""][""SessionToken""]}')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment