[aws] Fix switch_aws_profile when dealing with AWS_DEFAULT_REGION

This commit is contained in:
Daniel Carrillo 2020-02-22 19:41:14 +01:00
parent cb0099ec7a
commit a73bb314cc
2 changed files with 9 additions and 3 deletions

View File

@ -13,7 +13,7 @@ typeset -gA aws_info
if (( ${+AWS_PROFILE} )); then
if (( ${+AWS_DEFAULT_REGION+1} )) && [[ ${_aws_region} = "true" ]]; then
if (( ${+AWS_DEFAULT_REGION} )) && [[ ${_aws_region} = "true" ]]; then
AWS_REGION=$(cut -d "-" -f 1 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 2 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 3 <<<$AWS_DEFAULT_REGION | cut -b 1)
AWS_REGION_PROMPT=" $AWS_REGION"
fi

View File

@ -136,9 +136,15 @@ function ssh_aws_any {
function aws_switch_profile {
echo "Activating profile $1..."
export AWS_PROFILE=$1
local region
export AWS_PROFILE=$1
if [[ -f ~/.aws/credentials ]]; then #&& (( ! ${+AWS_DEFAULT_REGION} ))
export AWS_DEFAULT_REGION=$(aws configure get region)
region=$(aws configure get region)
if [[ ! -z $region ]]; then
export AWS_DEFAULT_REGION=$region
else
unset AWS_DEFAULT_REGION
fi
fi
}