Fix: Credential chaining from environment variables @lazize #996f

If profile is not defined, restore original credentials from environment variables,
if they exists, before assume-role
This commit is contained in:
Leonardo Azize Martins
2022-01-21 15:21:40 -03:00
committed by GitHub
parent ed558c857a
commit c120a31904
+5 -1
View File
@@ -14,7 +14,11 @@
assume_role(){
PROFILE_OPT=$PROFILE_OPT_BAK
if [[ "${PROFILE_OPT}" = "" ]]; then
# If profile is not defined, restore original credentials from environment variables, if they exists!
restoreInitialAWSCredentials
fi
# Both variables are mandatory to be set together
if [[ -z $ROLE_TO_ASSUME || -z $ACCOUNT_TO_ASSUME ]]; then
echo "$OPTRED ERROR!$OPTNORMAL - Both Account ID (-A) and IAM Role to assume (-R) must be set"