Last active
July 28, 2023 00:45
-
-
Save axelabs/5918ed31676fe92f844dd11283062317 to your computer and use it in GitHub Desktop.
Export selected AWS profile into environments π
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
# Usage from POSIX shell: . ./expAws.sh | |
PROFILES=$(awk configure list-profiles) | |
select PROFILE in $PROFILES; do | |
export AWS_ACCESS_KEY_ID="$(aws configure get aws_access_key_id --profile $PROFILE)" | |
export AWS_SECRET_ACCESS_KEY="$(aws configure get aws_secret_access_key --profile $PROFILE)" | |
export AWS_DEFAULT_REGION="$(aws configure get region --profile $PROFILE)" | |
export AWS_SESSION_TOKEN="$(aws configure get aws_session_token --profile $PROFILE)" | |
export AWS_SECURITY_TOKEN="$(aws configure get aws_security_token --profile $PROFILE)" | |
break | |
done | |
echo AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID | |
echo AWS_SECRET_ACCESS_KEY=$(echo $AWS_SECRET_ACCESS_KEY|tr '[:print:]' '*') | |
echo AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION | |
if [[ $AWS_SESSION_TOKEN ]] && [[ $AWS_SECURITY_TOKEN ]]; then | |
echo "AWS_*_TOKENS loaded" | |
else | |
unset AWS_SESSION_TOKEN AWS_SECURITY_TOKEN | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment