From 21a8193510c8981bce9eb220d8b08b2fefb051bc Mon Sep 17 00:00:00 2001 From: Jan Sepke <625043+jansepke@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:13:07 +0100 Subject: [PATCH] Fix issue #1001 (#1006) regression in extra75 Co-authored-by: Jan Sepke --- checks/check_extra75 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/checks/check_extra75 b/checks/check_extra75 index d4abe391..df480c87 100644 --- a/checks/check_extra75 +++ b/checks/check_extra75 @@ -37,12 +37,13 @@ extra75(){ if [[ $SECURITYGROUPS == "null" ]]; then continue fi - LIST_OF_SECURITYGROUPS=$(echo $SECURITYGROUPS | jq '.SecurityGroups|map({(.GroupId): (.GroupName)})|add' |jq -r 'to_entries|sort_by(.key)|.[]|.key') + SECURITYGROUP_NAMES=$(echo $SECURITYGROUPS | jq '.SecurityGroups|map({(.GroupId): (.GroupName)})|add') + LIST_OF_SECURITYGROUPS=$(echo $SECURITYGROUP_NAMES | jq -r 'to_entries|sort_by(.key)|.[]|.key') for SG_ID in $LIST_OF_SECURITYGROUPS; do SG_NOT_USED=$($AWSCLI ec2 describe-network-interfaces $PROFILE_OPT --region $regx --filters "Name=group-id,Values=$SG_ID" --query "length(NetworkInterfaces)" --output text) # Default security groups can not be deleted, so draw attention to them if [[ $SG_NOT_USED -eq 0 ]];then - GROUP_NAME=$(echo $SECURITYGROUPS | jq -r --arg id $SG_ID '.[$id]') + GROUP_NAME=$(echo $SECURITYGROUP_NAMES | jq -r --arg id $SG_ID '.[$id]') if [[ $GROUP_NAME != "default" ]]; then textFail "$regx: $SG_ID is not being used!" "$regx" "$SG_ID"