Check for errors generating credential report, limit loop iterations @zfLQ2qx2

Check for errors generating credential report, limit loop iterations @zfLQ2qx2
This commit is contained in:
Toni de la Fuente
2021-02-02 15:28:32 +01:00
committed by GitHub

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