From 8c9aea1231c8043ca42ed1ca17163fdd3dbcd38d Mon Sep 17 00:00:00 2001 From: Toni de la Fuente Date: Wed, 22 Apr 2020 13:54:17 +0200 Subject: [PATCH] Improved GetCallerIdentity handling / credentials --- include/whoami | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/whoami b/include/whoami index 4cc32d5d..3bd2b174 100644 --- a/include/whoami +++ b/include/whoami @@ -13,7 +13,16 @@ # Get whoami in AWS, who is the user running this shell script + ACCOUNT_NUM=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "Account") + +if [[ 255 -eq $? ]]; then + # Failed to get own identity ... exit + echo -e "$RED ERROR Getting credentials to run Prowler - EXITING! $NORMAL" + EXITCODE=2 + exit $EXITCODE +fi + CALLER_ARN=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "Arn") USER_ID=$($AWSCLI sts get-caller-identity --output text $PROFILE_OPT --region $REGION --query "UserId")