From da47558566b00c31a44074d2be12cfa09bac0b5f Mon Sep 17 00:00:00 2001 From: lavenderguitar Date: Tue, 23 May 2023 14:40:43 -0400 Subject: [PATCH] Variablize region and limit --- bash/delete_wafv1_rules.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bash/delete_wafv1_rules.sh b/bash/delete_wafv1_rules.sh index 59eb5e8..5fa82b7 100644 --- a/bash/delete_wafv1_rules.sh +++ b/bash/delete_wafv1_rules.sh @@ -1,7 +1,10 @@ #!/bin/bash +REGION="us-east-1" +LIMIT=50 + get_change_token() { - local response=$(aws waf get-change-token --region us-west-2) + local response=$(aws waf get-change-token --region $REGION) local change_token=$(echo "$response" | jq -r '.ChangeToken') echo "$change_token" } @@ -10,11 +13,11 @@ list_waf_rules() { local next_token="" while true; do - local response=$(aws waf list-rules --region us-west-2 --limit 50 --next-marker "$next_token") + local response=$(aws waf list-rules --region $REGION --limit $LIMIT --next-marker "$next_token") local rule_ids=($(echo "$response" | jq -r '.Rules[].RuleId')) for rule_id in "${rule_ids[@]}"; do - local rule_name=$(aws waf get-rule --region us-west-2 --rule-id "$rule_id" --query 'Rule.Name') + local rule_name=$(aws waf get-rule --region $REGION --rule-id "$rule_id" --query 'Rule.Name') echo "Rule ID: $rule_id, Rule Name: $rule_name" done @@ -30,12 +33,12 @@ delete_waf_rules() { local next_token="" while true; do - local response=$(aws waf list-rules --region us-west-2 --limit 50 --next-marker "$next_token") + local response=$(aws waf list-rules --region $REGION --limit $LIMIT --next-marker "$next_token") local rule_ids=($(echo "$response" | jq -r '.Rules[].RuleId')) for rule_id in "${rule_ids[@]}"; do echo "Deleting Rule ID: $rule_id" - aws waf delete-rule --region us-west-2 --rule-id "$rule_id" --change-token "$change_token" + aws waf delete-rule --region $REGION --rule-id "$rule_id" --change-token "$change_token" done local next_token=$(echo "$response" | jq -r '.NextMarker')