Last active
November 26, 2024 13:40
-
-
Save DrJume/5b7d081cfd5493b4bf6d2fa09ec7f241 to your computer and use it in GitHub Desktop.
Cloudflare zone settings overview as table
This file contains 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 | |
# parameters | |
CF_API_EMAIL= | |
CF_API_KEY= | |
# specify the id for a zone (domain) | |
# get it via the Cloudflare Dashboard | |
# of via flarectl: https://github.com/cloudflare/cloudflare-go/tree/master/cmd/flarectl | |
CF_ZONE= | |
# fetch data from Cloudflare API in JSON format | |
curl -X GET "https://api.cloudflare.com/client/v4/zones/$CF_ZONE/settings" \ | |
-H "X-Auth-Email: $CF_API_EMAIL" -H "X-Auth-Key: $CF_API_KEY" -H "Content-Type: application/json" \ | |
> "zone-settings-$CF_ZONE.json" | |
# filter & format JSON to CSV | |
# download jq from https://stedolan.github.io/jq/ | |
cat "zone-settings-$CF_ZONE.json" | jq -r '[.result[] | {id, value} | to_entries | map(.value) | map(tostring)] | .[] | join(";")' \ | |
> "zone-settings-$CF_ZONE.csv" | |
# visualize CSV as a table in the terminal | |
cat "zone-settings-$CF_ZONE.csv" | column -s';' -t -c 80 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment