Created
January 30, 2018 20:50
-
-
Save tmclaugh/76a2c5c260d5b97058208abc721e5bd8 to your computer and use it in GitHub Desktop.
goaws() bash function
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
goaws () { | |
PROFILE=$1 | |
export AWS_REGION='us-east-1' | |
export AWS_DEFAULT_PROFILE=$PROFILE | |
# this will override the profile used by some tools so let's not set that | |
# even though it's standard. | |
#export AWS_PROFILE=$PROFILE | |
export _SLS_STAGE=$(echo $AWS_DEFAULT_PROFILE | cut -s -d '-' -f 2) | |
export SLS_STAGE=${_SLS_STAGE:-prime} | |
# Not needed since we have AWS_DEFAULT_PROFILE set. That changes if we have | |
# commands that try and reference these which I hope isn't the case. | |
#export AWS_ACCESS_KEY=$(tail -n 1 ~/.aws/credentials-${PROFILE}.csv | cut -d, -f 1) | |
#export AWS_SECRET_ACCESS_KEY=$(tail -n 1 ~/.aws/credentials-${AWS_PROFILE}.csv | cut -d, -f 2) | |
if [ -f ~/.aws/accountId-${PROFILE} ]; then | |
export AWS_ACCOUNT_ID="$(cat ~/.aws/accountId-${PROFILE})" | |
else | |
unset AWS_ACCOUNT_ID | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment