-
-
Save Laxman-SM/6a4aa811dd1ed6ac9b841a8aa6582ef8 to your computer and use it in GitHub Desktop.
Assume AWSControlTowerExecution from management account
This file contains hidden or 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 | |
export AWS_REGION="us-west-2" | |
account_id=$1 | |
temp_role=$(aws sts assume-role \ | |
--role-arn "arn:aws:iam::${account_id}:role/AWSControlTowerExecution" \ | |
--role-session-name "aws-ct-mgmt") | |
unset AWS_ACCESS_KEY_ID | |
unset AWS_SECRET_ACCESS_KEY | |
unset AWS_SESSION_TOKEN | |
export AWS_ACCESS_KEY_ID=$(echo $temp_role | jq -r .Credentials.AccessKeyId) | |
export AWS_SECRET_ACCESS_KEY=$(echo $temp_role | jq -r .Credentials.SecretAccessKey) | |
export AWS_SESSION_TOKEN=$(echo $temp_role | jq -r .Credentials.SessionToken) | |
env | grep -i AWS_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment