From 272528b4392781bf77f0791ff0110a4d75ce17f0 Mon Sep 17 00:00:00 2001 From: dcarrillo Date: Sat, 22 Feb 2020 20:04:40 +0100 Subject: [PATCH] [aws] Add function for deactivating (unset variables) current aws profile --- modules/aws/init.zsh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/aws/init.zsh b/modules/aws/init.zsh index dc2cc26..51920ca 100644 --- a/modules/aws/init.zsh +++ b/modules/aws/init.zsh @@ -135,9 +135,14 @@ function ssh_aws_any { } function aws_switch_profile { - echo "Activating profile $1..." local region + if [[ -z $1 ]]; then + echo "Profile can't be an empty string" + return 1 + fi + + echo "Activating profile $1..." export AWS_PROFILE=$1 if [[ -f ~/.aws/credentials ]]; then #&& (( ! ${+AWS_DEFAULT_REGION} )) region=$(aws configure get region) @@ -148,3 +153,9 @@ function aws_switch_profile { fi fi } + +function aws_deactivate_profile { + echo "Deactivating aws profile..." + unset AWS_PROFILE + unset AWS_DEFAULT_REGION +}