bvrinfra.in
Colour theme

DNS · published 8 October 2026

Why DNS changes need a manual apply

Managing DNS as code prevents silent drift and forgotten records. For bvrinfra.in, every DNS change goes through a pull request and a speculative plan, but live updates wait for a human to confirm and apply them. Here is why.

The 22 stale records

When I started the rebuild in October 2026, after the September outage, the DNS zone for bvrinfra.in still held 22 stale records.

Seventeen of those records pointed to a deleted Cloudflare Tunnel. One pointed to a private address on my home network. The remaining records pointed to a deleted virtual machine or projects that had ended.

None of these records caused an immediate incident on their own, but together they represented unmanaged drift accumulated over time through hand edits in the web dashboard. There was no recorded intent, no review process, and no easy way to know if a record was still needed.

DNS as code with Terraform

To fix this, I imported the DNS records into Terraform using the Cloudflare provider, with state stored in HCP Terraform under the bvrinfra-dns workspace. The dashboard is now considered read-only by convention.

All zone records are defined in infra/terraform/main.tf inside a local.records map. To prevent accidental record deletions, every record resource includes a prevent_destroy = true lifecycle guardrail. Deleting a record requires a pull request that explicitly removes that guard first.

The plan-on-PR workflow

When a DNS change is needed, the process follows three distinct stages:

  1. Pull request: A branch updates infra/terraform/main.tf. GitHub Actions checks syntax and formatting without holding production credentials.
  2. Speculative plan: HCP Terraform automatically runs a speculative plan against live Cloudflare DNS and links the result from the pull request's checks.
  3. Merge and queue: Merging the PR triggers a production plan on main in HCP Terraform, which pauses and waits for manual approval.

Why auto-apply is turned off

Auto-applying infrastructure changes on merge can be risky when automated tools or AI assistants draft code. Under ADR 0001 (D7), AI agents work strictly in the build loop to draft pull requests, and no automated tool holds credentials to apply live infrastructure changes unattended.

Requiring a human operator to log into HCP Terraform, review the queued plan against the merged PR, and click Confirm & apply provides a deliberate circuit breaker. It means no change reaches Cloudflare through Terraform until I have read the plan.

Summary

Hand edits caused 22 stale records. Terraform enforces structure and intent in code, and manual apply means every DNS change through Terraform waits for my sign-off.