From c120a319045fdd89a2a841a3ae16a7bd876cbbf4 Mon Sep 17 00:00:00 2001 From: Leonardo Azize Martins Date: Fri, 21 Jan 2022 15:21:40 -0300 Subject: [PATCH] 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 --- include/assume_role | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/assume_role b/include/assume_role index a125bce9f13..7f94b4fd0c8 100644 --- a/include/assume_role +++ b/include/assume_role @@ -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"