Skip to content

Instantly share code, notes, and snippets.

@tmclaugh
Created January 30, 2018 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmclaugh/76a2c5c260d5b97058208abc721e5bd8 to your computer and use it in GitHub Desktop.
Save tmclaugh/76a2c5c260d5b97058208abc721e5bd8 to your computer and use it in GitHub Desktop.
goaws() bash function
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