Skip to content

Instantly share code, notes, and snippets.

@activeshadow
Created February 14, 2019 21:04
Show Gist options
  • Save activeshadow/5c9f8c5a8c35b8abd5cbc39101b84552 to your computer and use it in GitHub Desktop.
Save activeshadow/5c9f8c5a8c35b8abd5cbc39101b84552 to your computer and use it in GitHub Desktop.
Remove AWS WAF Rules
#!/bin/bash
RULES=$(aws waf list-rules | jq -r ".Rules[] | .RuleId")
for rule in $RULES; do
TOKEN=$(aws waf get-change-token | jq -r .ChangeToken)
PRED=$(aws waf get-rule --rule-id $rule | jq ".Rule.Predicates[0]")
aws waf update-rule --cli-input-json '{"RuleId": "'$rule'", "ChangeToken": "'$TOKEN'", "Updates": [{"Action": "DELETE", "Predicate": '"$PRED"'}]}'
TOKEN=$(aws waf get-change-token | jq -r .ChangeToken)
aws waf delete-rule --rule-id $rule --change-token $TOKEN
sleep 1
done
@aclarknexient
Copy link

Thank you for sharing this! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment