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

[aws] Detect whenever a aws sso login is needed

This commit is contained in:
Daniel Carrillo 2022-06-12 16:22:24 +02:00
parent 2676780766
commit 3d3346be0a

View File

@ -148,6 +148,7 @@ function ssh_aws_any {
function aws_switch_profile {
local region
local credentials
if [[ -z $1 ]]; then
echo "Profile can't be an empty string"
@ -166,7 +167,14 @@ function aws_switch_profile {
fi
if [[ ${_aws_sso} == "true" ]]; then
eval $(aws-export-credentials --env-export)
credentials=$(aws-export-credentials --env-export 2>&1)
if [[ $credentials =~ "has expired" ]]; then
aws sso login
credentials=$(aws-export-credentials --env-export)
fi
eval $credentials
fi
fi
}