diff --git a/modules/aws/functions/aws-info b/modules/aws/functions/aws-info index 546b445..1035548 100644 --- a/modules/aws/functions/aws-info +++ b/modules/aws/functions/aws-info @@ -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 diff --git a/modules/aws/init.zsh b/modules/aws/init.zsh index b1e5b91..dc2cc26 100644 --- a/modules/aws/init.zsh +++ b/modules/aws/init.zsh @@ -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 }