We have several hundred zones that we’d like to import into Cloudflare. The DNS records for these zones are managed with some in-house tooling which writes out to BIND formatted zone files. Using the API, we can import these zone files for each domain. However, if a change is made to the zone file, for example updating the A records for $EXAMPLE_DOMAIN (e.g. change A record for $EXAMPLE_DOMAIN from 127.0.0.1 to 127.0.0.2) the next zone file import for that domain APPENDS the new A record resulting in two A records for $EXAMPLE_DOMAIN (i.e. 127.0.0.1 and 127.0.0.2). Is there any way that I can force the import to result in the same records as the imported zone file? Do I need to delete every record before I import the zone file? Is there a quick way to do this without iterating over each record with a delete action? With the number of domains that we’re going to managing we’d end up hitting rate limits.
Generally we look at importing via a BIND file as a one time affair to seed the zone with the initial starting values. So no way to overwrite vs add/mark identical as duplicate. For doing updates I would recommend either calling the API to patch the existing record or look at a tool like Terraform to manage the records. You could diff the last BIND file with the current to find changes and then call our API to patch existing records or add/remove records as needed.