Skip to content

Commit

Permalink
Fix: Credential chaining from environment variables @lazize #996f
Browse files Browse the repository at this point in the history
If profile is not defined, restore original credentials from environment variables,
if they exists, before assume-role
  • Loading branch information
lazize authored Jan 21, 2022
1 parent ed558c8 commit c120a31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/assume_role
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c120a31

Please # to comment.