Last active
April 8, 2018 02:36
-
-
Save washcycle/e964aeb882b62b0a4340567338ae279c to your computer and use it in GitHub Desktop.
AWS CLI Configuration Switch Bash Script
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
# configure aws credentials while on corporate network | |
function aws_config_work(){ | |
# assumes $WORK_AWS_ACCESS_KEY, $WORK_AWS_SECRET_ACCESS_KEY, $WORK_AWS_DEFAULT_REGION, $CA_PATH | |
# are user or system evironment variables | |
# environment variables are UPPERCASE even in git bash | |
export AWS_ACCESS_KEY_ID=$WORK_AWS_ACCESS_KEY | |
export AWS_SECRET_ACCESS_KEY=$WORK_AWS_SECRET_ACCESS_KEY | |
export AWS_DEFAULT_REGION=$WORK_AWS_DEFAULT_REGION | |
export AWS_CA_BUNDLE=$CA_PATH | |
env | grep -e _PROXY -e GIT_ | sort | |
# echo -e "\nProxy-related environment variables set." | |
# clear | |
} | |
# Enable work aws configuration by default | |
aws_config_work | |
# Disable proxy settings | |
function aws_config_mine(){ | |
variables=( \ | |
"AWS_ACCESS_KEY_ID" "AWS_SECRET_ACCESS_KEY" "AWS_CA_BUNDLE" "AWS_DEFAULT_REGION" \ | |
) | |
for i in "${variables[@]}" | |
do | |
unset $i | |
done | |
env | grep -e _PROXY -e GIT_ | sort | |
echo -e "\nProxy-related environment variables removed." | |
} | |
function aws_config_off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment