Created
July 11, 2016 14:40
-
-
Save ankona/1c7f7898057bbb4da0ecb6a7b437178c to your computer and use it in GitHub Desktop.
STS Assume Role (BASH)
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
role_result=$(aws sts assume-role --role-arn "%deployer_arn%" --role-session-name "deploy-dynamo-assets" --external-id "%assume_role_external_id%") | |
secret_key=$(echo $role_result | python -mjson.tool | grep "SecretAccessKey" | awk -F':' '{print $2}'| sed "s/[ |\"|,]//g") | |
session_token=$(echo $role_result | python -mjson.tool | grep "SessionToken" | awk -F':' '{print $2}'| sed "s/[ |\"|,]//g") | |
access_key=$(echo $role_result | python -mjson.tool | grep "AccessKeyId" | awk -F':' '{print $2}'| sed "s/[ |\"|,]//g") | |
echo "##teamcity[setParameter name='env.AWS_SECRET_ACCESS_KEY' value='${secret_key}']" | |
echo "##teamcity[setParameter name='env.AWS_SECURITY_TOKEN' value='${session_token}']" | |
echo "##teamcity[setParameter name='env.AWS_ACCESS_KEY_ID' value='${access_key}']" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment