From 57061594ee525d7d3f7c649d8084cbea0b1e38c9 Mon Sep 17 00:00:00 2001 From: lavenderguitar Date: Tue, 23 May 2023 14:38:58 -0400 Subject: [PATCH] Accommodate the change-token option --- bash/delete_wafv1_rules.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bash/delete_wafv1_rules.sh b/bash/delete_wafv1_rules.sh index a8763ad..59eb5e8 100644 --- a/bash/delete_wafv1_rules.sh +++ b/bash/delete_wafv1_rules.sh @@ -1,5 +1,11 @@ #!/bin/bash +get_change_token() { + local response=$(aws waf get-change-token --region us-west-2) + local change_token=$(echo "$response" | jq -r '.ChangeToken') + echo "$change_token" +} + list_waf_rules() { local next_token="" @@ -20,6 +26,7 @@ list_waf_rules() { } delete_waf_rules() { + local change_token=$(get_change_token) local next_token="" while true; do @@ -28,7 +35,7 @@ delete_waf_rules() { 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" + aws waf delete-rule --region us-west-2 --rule-id "$rule_id" --change-token "$change_token" done local next_token=$(echo "$response" | jq -r '.NextMarker')