From e8454032ec60a3c0e944bd9dce8f9fbddf62888f Mon Sep 17 00:00:00 2001 From: lavenderguitar Date: Thu, 18 May 2023 13:19:46 -0400 Subject: [PATCH] Delete WAF rules script --- bash/delete_waf_rules.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bash/delete_waf_rules.sh diff --git a/bash/delete_waf_rules.sh b/bash/delete_waf_rules.sh new file mode 100644 index 0000000..f068a38 --- /dev/null +++ b/bash/delete_waf_rules.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +list_waf_rules() { + aws wafv2 list-rules --scope REGIONAL --region us-west-2 +} + +delete_waf_rules() { + local rule_ids=($(aws wafv2 list-rules --scope REGIONAL --region us-west-2 --query 'Rules[].RuleId' --output text)) + + for rule_id in "${rule_ids[@]}"; do + echo "Deleting Rule ID: $rule_id" + aws wafv2 delete-rule --name "$rule_id" --scope REGIONAL --region us-west-2 + done +} + +list_waf_rules + +read -p "Do you want to delete all the listed WAF rules? (yes/no): " response +if [[ "$response" == "yes" ]]; then + delete_waf_rules + echo "All WAF rules have been deleted." +else + echo "No WAF rules have been deleted." +fi