1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 18:38:00 +00:00

[aws] Add function to activate and switch profiles taken from aws credentials file

This commit is contained in:
Daniel Carrillo 2020-02-22 16:11:38 +01:00
parent 3d827cdb88
commit fc8f82329b
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,13 @@
#compdef aws_switch_profile
#autoload
if [[ ! -f ~/.aws/credentials ]]; then
return 1
fi
local profiles
profiles=$(grep -E "^\[.+\]" ~/.aws/credentials | tr -d '[' | tr -d ']' )
_arguments "1:toggle:((
$profiles
))" && return 0

View File

@ -127,3 +127,12 @@ function aws_cf {
function ssh_aws_any { function ssh_aws_any {
aws_ssm_session_any $1 ssh aws_ssm_session_any $1 ssh
} }
function aws_switch_profile {
echo "Activating profile $1..."
export AWS_PROFILE=$1
if [[ -f ~/.aws/credentials ]]; then #&& (( ! ${+AWS_DEFAULT_REGION} ))
export AWS_DEFAULT_REGION=$(aws configure get region)
fi
}