1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 12:48:01 +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 { function aws_switch_profile {
local region local region
local credentials
if [[ -z $1 ]]; then if [[ -z $1 ]]; then
echo "Profile can't be an empty string" echo "Profile can't be an empty string"
@ -166,7 +167,14 @@ function aws_switch_profile {
fi fi
if [[ ${_aws_sso} == "true" ]]; then 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
fi fi
} }