Skip to content

Instantly share code, notes, and snippets.

@activeshadow
Created February 14, 2019 21:02
Show Gist options
  • Save activeshadow/ff5a03b1c457334458514e1b35bac9b9 to your computer and use it in GitHub Desktop.
Save activeshadow/ff5a03b1c457334458514e1b35bac9b9 to your computer and use it in GitHub Desktop.
Remove AWS WAF ACLs
#!/bin/bash
ACLS=$(aws waf list-web-acls | jq -r ".WebACLs[] | .WebACLId")
for acl in $ACLS; do
TOKEN=$(aws waf get-change-token | jq -r .ChangeToken)
RULE=$(aws waf get-web-acl --web-acl-id $acl | jq ".WebACL.Rules[0]")
aws waf update-web-acl --cli-input-json '{"WebACLId": "'$acl'", "ChangeToken": "'$TOKEN'", "Updates": [{"Action": "DELETE", "ActivatedRule": '"$RULE"'}]}'
TOKEN=$(aws waf get-change-token | jq -r .ChangeToken)
aws waf delete-web-acl --web-acl-id $acl --change-token $TOKEN
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment