bash script to update all dns records on cloudflare zone if hetrixtools api return offline
Hi, I need to know if is possible to update all dns records on a domain (A, AAAA) using cloudflare api or i need to write every dns record manually.
I want to check if "X" server status goes offline using hetrixtools api and change all A and AAAA entries with new ipv4/v6
I managed to make this work https://gist.github.com/Tras2/cba88201b17d765ec065ccbedfb16d9a with a single A record but don't know how to make it to do massively on all existing dns records and i have like 20 which i need to include
appreacited if someone can guide me or share a example
Comments
If CF's internal dns record id and zone id are constants you can make just one api call to update the thing.
Then I found this: https://community.cloudflare.com/t/no-longer-able-to-update-dns-records-via-api/143942/59
So the script must try PUT method first, then PATCH method if PUT fails, then maybe even DELETE record as the last resort and recreate it with a new value, but you must be sure that creation of a new record works on a dummy record before deleting existing one to recreate it. Or import new records with POST zones/:zone_identifier/dns_records/import after successful DELETE. Crazy stuff!
Route53 would be easier - https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover.html
Also, ClouDNS has DNS Failover as well - https://www.cloudns.net/dns-failover/
well, since i don't need cloudflare proxy, i'm moving my domain to cloudns.net (thanks for suggest it)... they have which i was looking and more simplified
https://www.cloudns.net/wiki/article/282/