Browse Source

Accommodate the change-token option

master
lavenderguitar 2 years ago
parent
commit
57061594ee
  1. 9
      bash/delete_wafv1_rules.sh

9
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')

Loading…
Cancel
Save