Created
August 19, 2021 15:55
-
-
Save kruligh/e0866461f5b9698a0d56aafe795248e8 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 | |
if [[ -z "$ROLE_ARN" ]]; then | |
echo "==> skipping assume role as no role specified" | |
return | |
fi | |
echo "==> assuming role $ROLE_ARN" | |
output=$(aws sts assume-role --role-arn "$ROLE_ARN" --role-session-name "assumed-role") | |
echo "==> role $ROLE_ARN assumed" | |
export AWS_ACCESS_KEY_ID=$(echo $output | jq -c '.Credentials.AccessKeyId' | tr -d '"' | tr -d ' ') | |
export AWS_SECRET_ACCESS_KEY=$(echo $output | jq -c '.Credentials.SecretAccessKey' | tr -d '"' | tr -d ' ') | |
export AWS_SESSION_TOKEN=$(echo $output | jq -c '.Credentials.SessionToken' | tr -d '"' | tr -d ' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment