Check for errors generating credential report, limit loop iterations

This commit is contained in:
C.J
2021-01-14 04:41:16 -05:00
parent 6cbee3b16c
commit be3e771454

View File

@@ -14,9 +14,19 @@
# Generate Credential Report
genCredReport() {
textTitle "0.1" "Generating AWS IAM Credential Report..." "NOT_SCORED" "SUPPORT"
until $( $AWSCLI iam generate-credential-report --output text --query 'State' $PROFILE_OPT --region $REGION |grep -q -m 1 "COMPLETE") ; do
for i in $(seq 1 60); do
GENERATECREDENTIALREPORTOUTPUT=$($AWSCLI iam generate-credential-report --output text --query 'State' $PROFILE_OPT --region $REGION 2>&1)
if [[ $(echo "$GENERATECREDENTIALREPORTOUTPUT" | grep AccessDenied) ]]; then
textFail "Access Denied trying to generate credential report"
exit 1
fi
if [[ "$GENERATECREDENTIALREPORTOUTPUT" == "COMPLETE" ]]; then
return
fi
sleep 1
done
textFail "Generate credential report unsuccessful"
exit 1
}
# Save report to a file, decode it, deletion at finish and after every single check