mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 12:48:01 +00:00
[aws] Add function to activate and switch profiles taken from aws credentials file
This commit is contained in:
parent
3d827cdb88
commit
fc8f82329b
13
modules/aws/functions/_aws_switch_profile
Normal file
13
modules/aws/functions/_aws_switch_profile
Normal 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
|
@ -127,3 +127,12 @@ function aws_cf {
|
||||
function ssh_aws_any {
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user