Created
July 6, 2017 10:28
-
-
Save dougneal/bcdebd8af05ddfec8beee5f3c1c35f93 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -eu | |
arn="$1" | |
session="$2" | |
response="$(aws sts assume-role --role-arn "$arn" --role-session-name "$session")" | |
AWS_ACCESS_KEY_ID="$(echo "$response" | jq -r '.Credentials.AccessKeyId')" | |
AWS_SECRET_ACCESS_KEY="$(echo "$response" | jq -r '.Credentials.SecretAccessKey')" | |
AWS_SESSION_TOKEN="$(echo "$response" | jq -r '.Credentials.SessionToken')" | |
echo "export AWS_ACCESS_KEY_ID=\"${AWS_ACCESS_KEY_ID}\"" | |
echo "export AWS_SECRET_ACCESS_KEY=\"${AWS_SECRET_ACCESS_KEY}\"" | |
echo "export AWS_SESSION_TOKEN=\"${AWS_SESSION_TOKEN}\"" | |
echo "Expiry: $(echo "$response" | jq -r '.Credentials.Expiration') Now: $(date)" > /dev/stderr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment