Created
March 29, 2021 13:26
-
-
Save MOZGIII/a5fce318d95a5af09dcc69fec75fdef2 to your computer and use it in GitHub Desktop.
Bulk DNS records removal from Cloudflare
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 | |
set -euo pipefail | |
AUTH_TOKEN="$1" | |
ZONE_ID="$2" | |
api() { | |
curl -sSL -H "Authorization: Bearer $AUTH_TOKEN" "$@" | |
} | |
get_records() { | |
api "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" | |
} | |
delete_record() { | |
local ID="$1" | |
api -X DELETE "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$ID" | |
} | |
IDS=$(get_records | jq -r '.result | .[].id') | |
for ID in $IDS; do | |
echo "$ID" | |
delete_record "$ID" | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment