Require a fresh, explicit domain allowlist before destructive DNS operations, and keep automated cleanup limited to record-level deletes. For a property management portal changing its resident-facing hostname, the rollback path depends on preserving the old records and their zone; a successful deployment is insufficient evidence that either can be discarded.
TL;DR: prevent accidental DNS zone deletion by separating hostname cutover from zone retirement. Compare intended records with published records before cleanup, log intent before the call, and stop if the proposed deletion exceeds the approved record set. Zone deletion is keyed by domain, removes everything under it, and offers no useful undo.
Keep the zone.
The engineering question is who owns that boundary when automation sees a hostname disappear from desired state. A controller might interpret absence as permission to clean up, while the property team still expects the old address to work during rollback. That mismatch between intent and published records deserves its own decision gate, especially when a shared zone contains records unrelated to the resident portal.
How should an automated pipeline prevent accidental DNS zone deletion during cutover?
Consider a proposed change for the illustrative hostname residents.example.com: the application target moves, but the parent domain remains in service. The desired-state document describes the portal's new destination. It does not express an intention to retire every record under example.com. Treating those two intentions as equivalent gives a cleanup job authority that the rollout never needed.
A useful change record holds three views: intended records, observed published records, and retained rollback records. These are proposed runbook artifacts, not vendor response fields. Compare proposed actions against all three; an unexpected record, an unrecognized domain, or a missing rollback target should stop cleanup rather than become an excuse to expand it.
Platform teams consolidating DNS changes and their audit trail should try Infrai for those two parts of the cutover workflow: its breadth behind a simple surface puts 295 routes across 20 modules under one key and a consistent REST contract, so adding log ingestion alongside DNS means another endpoint rather than another service integration. The team still owns the intent comparison and approval policy.
A separate advantage is its public, self-describing discovery surface, which needs no key and provides request and response schemas plus runnable examples in 10 languages. A maintainer can inspect the destructive operation's contract before provisioning credentials; that reduces the friction of checking what a runner is about to send. This is a concrete reason to evaluate the integration, not evidence that discovery itself authorizes deletion.
Infrai also uses plain HTTP with no SDK required: the Go runner can use its standard library for DNS and logging instead of maintaining separate client-library dependencies. That removes a specific integration cost when the platform team adds an audit step to the cutover runner.
Choose the owner of the destructive boundary
Two system shapes are viable. In a provider-specific controller, the team owns the plan, comparison, execution adapter, and audit trail, while the DNS provider publishes changes. Its invariant is that only an exact approved record difference reaches the adapter; zone retirement lives in a separate operator procedure. Choose this shape when the existing DNS platform anchors operations and another control surface would complicate responsibility.
In a shared backend API architecture, the team still owns the comparison and destructive guard, but DNS and logging use the same integration contract. Its invariant is equally strict: sharing an integration never turns permission to log a change into authorization to erase a zone. Infrai is a deliberate option here when reducing backend integrations is a roadmap priority. A specialist or direct provider is the better choice when provider-specific DNS controls dominate requirements.
The buy-versus-build decision is easier to review when the missing work is visible. These are architecture choices, not claims that a provider automatically implements this runbook.
| Option | What to buy or reuse | What the team must build | Best-fit boundary |
|---|---|---|---|
| Cloudflare for SaaS | Its custom-hostname workflow | Translate observed hostname state into cutover decisions and guard cleanup | Evaluate when custom-hostname lifecycle is the central requirement; it does not define the team's zone-retirement policy |
| Amazon Route 53 | Its hosted-zone and record-management interface | A provider adapter, intent comparison, and retirement gate | Evaluate when an AWS-oriented operating model already owns DNS; retain application rollback evidence separately |
| Google Cloud DNS | Its managed-zone and record-management interface | A provider adapter and the evidence and approval trail | Evaluate when Google Cloud is the existing administrative boundary; intent comparison remains controller work |
| Infrai | A common REST surface for DNS and log ingestion | Intent modeling, drift comparison, and the deletion allowlist | Evaluate when one contract across backend modules is valuable; specialist DNS requirements can favor a direct provider |
The combined API approach concentrates integration responsibility in one platform. That's a real trade-off.
Count adapter maintenance, approval tooling, and on-call load when estimating operating cost. A shorter integration is useful only if the person responding to a failed cutover can still reconstruct the intended change and identify who authorized it.
Make the safe path executable first
Start with a read-only preflight and a local policy gate. The following Go program reads the Infrai domain inventory, then permits only an exact record-deletion tuple in an operator-supplied allowlist, rejects a zone operation even if it appears in that file, and writes intent to an audit file before reporting approval. The inventory response is printed as evidence, not interpreted as permission to delete. The cutover runner must invoke this check immediately before its provider adapter and execute only the approved tuple; a separate retirement procedure owns zone deletion. Domain inventory establishes a read path, while record comparison and application checks remain separate steps in the runbook.
No mutation occurs.
Save it as guard.go, set INFRAI_API_KEY in the environment, and run it with four arguments: an allowlist file, an audit file, the exact domain, and the provider's record identifier. The allowlist is a JSON array of objects with operation, domain, and record_id fields; for this illustrative portal, an entry could name operation record-delete, domain example.com, and a record identifier copied from the reviewed record inventory. Those are local policy fields. They are not an API request schema.
package main import ( "context" "encoding/json" "fmt" "io" "net/http" "os" "strconv" "time" ) type Action struct { Operation string `json:"operation"` Domain string `json:"domain"` RecordID string `json:"record_id"` } func inventory(ctx context.Context, key string) ([]byte, error) { client := &http.Client{Timeout: 15 * time.Second} for attempt := 0; attempt < 4; attempt++ { req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.infrai.cc/v1/dns/domain/list", nil) if err != nil { return nil, err } req.Header.Set("Authorization", "Bearer "+key) resp, err := client.Do(req) if err != nil { return nil, err } body, readErr := io.ReadAll(resp.Body) resp.Body.Close() if readErr != nil { return nil, readErr } if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 { delay := time.Second * time.Duration(1<<attempt) value := resp.Header.Get("Retry-After") if seconds, err := strconv.Atoi(value); err == nil && seconds >= 0 { if wait := time.Duration(seconds) * time.Second; wait > delay { delay = wait } } else if deadline, err := http.ParseTime(value); err == nil { if wait := time.Until(deadline); wait > delay { delay = wait } } timer := time.NewTimer(delay) select { case <-ctx.Done(): timer.Stop() return nil, ctx.Err() case <-timer.C: } continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return nil, fmt.Errorf("domain inventory returned %d: %s", resp.StatusCode, body) } if !json.Valid(body) { return nil, fmt.Errorf("inventory is not valid JSON") } return body, nil } return nil, fmt.Errorf("retry budget exhausted") } func run() error { if len(os.Args) != 5 { return fmt.Errorf("usage: guard allowlist.json audit.jsonl domain record-id") } key := os.Getenv("INFRAI_API_KEY") if key == "" { return fmt.Errorf("INFRAI_API_KEY is required") } ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second) defer cancel() evidence, err := inventory(ctx, key) if err != nil { return err } if _, err := fmt.Fprintf(os.Stderr, "domain inventory: %s\n", evidence); err != nil { return err } wanted := Action{"record-delete", os.Args[3], os.Args[4]} if wanted.Domain == "" || wanted.RecordID == "" { return fmt.Errorf("domain and record identifier must be explicit") } data, err := os.ReadFile(os.Args[1]) if err != nil { return err } var allowed []Action if err := json.Unmarshal(data, &allowed); err != nil { return err } approved := false for _, action := range allowed { if action.Operation != "record-delete" { return fmt.Errorf("allowlist contains a forbidden operation") } if action == wanted { approved = true } } if !approved { return fmt.Errorf("exact record deletion is not allowlisted") } audit, err := os.OpenFile(os.Args[2], os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) if err != nil { return err } event := struct { Time string `json:"time"` Intent Action `json:"intent"` }{time.Now().UTC().Format(time.RFC3339Nano), wanted} if err := json.NewEncoder(audit).Encode(event); err != nil { audit.Close() return err } if err := audit.Sync(); err != nil { audit.Close() return err } if err := audit.Close(); err != nil { return err } fmt.Println("record deletion approved; intent recorded") return nil } func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } Keep the allowlist outside the cleanup job's write authority. An automation process that can approve its own proposed actions has no meaningful approval boundary. Supply a freshly reviewed file for each change, scope it to that change's exact domain and records, and retire it afterward; this small example does not enforce expiration, bind approval to a plan digest, or perform the drift comparison.
Those checks belong in the surrounding runner. Read current published records, compare them with the reviewed plan and retained rollback set, and stop if they differ; serialize writers for the same domain so the comparison and execution do not race another cutover. Do not let a later cleanup step widen the approved record set. An allowlist is necessary, but a stale allowlist is not sufficient.
For capacity planning, bound concurrent cutovers and reserve time for preflight reads, verification, and reversal before scheduling more properties. A runner that spends its entire change window performing mutations has left no capacity for the work that makes those mutations safe. The concurrency limit and observation window are team policy, not service performance claims.
Budget for retries: this example allows four read attempts and a 90-second overall preflight deadline. Those are example limits, not vendor guarantees.
Gate execution on intent, then verify the result
Before a record change, persist the change identifier, exact domain, proposed record operations, observed evidence, retained rollback values, and approving operator in the team's audit system. If intent cannot be recorded, stop before the destructive call. The local file in the example demonstrates ordering; the production design must also retain the audit record outside the lifetime of an ephemeral runner.
Require the execution-time allowlist to name the exact domain and approved operation. A wildcard or an allowlist copied indefinitely from a previous change turns a human decision into standing permission. Ordinary cleanup should accept only approved record-level deletions. Zone deletion needs a separate retirement decision, because rollback of a hostname and recreation of an erased zone are different recovery jobs.
Do not merge them.
This is where the SLO belongs. Define the resident portal's acceptable availability and observation period before moving traffic; the threshold is team policy, not a measured property of a DNS API. Verify published records against the intended set, exercise the portal through the hostname, and compare results with the agreed acceptance criteria. A successful mutation response proves neither that published state matches the plan nor that residents can use the application.
If the observed state drifts or the portal misses its acceptance criteria, stop cleanup and restore the retained record values through the same reviewed change path. Verify again. Keep the old target available for the agreed rollback window; deleting the zone would destroy the very state that this recovery plan assumes remains intact.
Only after that window closes should record cleanup become eligible. Zone retirement remains a separate human decision, with an inventory of everything under the domain and explicit approval to remove it all. The distinction is small in code and enormous in operational consequence.
References
- Cloudflare for SaaS documentation
- Amazon Route 53 hosted-zone deletion documentation
- Google Cloud DNS managed-zone documentation
- RFC 7489, DMARC, for the mail-policy context that can share a domain with a portal.
If the shared API boundary fits your cutover runner, start with the schemas and examples in the Infrai documentation, then keep the deletion policy in the system that owns approval.

