Created
February 14, 2019 21:04
-
-
Save activeshadow/5c9f8c5a8c35b8abd5cbc39101b84552 to your computer and use it in GitHub Desktop.
Remove AWS WAF Rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing this! :)