ADR-0046: The weekly drift run exports the zone and fails on records OpenTofu does not manage#

  • Status: accepted. Extends ADR-0021.
  • Date: 2026-12-01

Context#

Drift detection plans main against production (ADR-0021). A plan refreshes only what is in state, so a record created in the zone by hand, by a compromised role or by another tool is invisible to it. Such a record would be served, and signed, as the zone's own. Certificate Transparency catches a certificate issued for a new name (ADR-0033), but not a TXT record proving control of the domain to a third party, an NS record delegating a name away, or an address record pointing a name somewhere else.

Nothing keeps a record of what the zone served, either: state holds what OpenTofu manages, and the website's DNS table is generated from configuration.

The constraints: no new workflow or grant where an existing one will do (principle 10, ADR-0029); the job that holds AWS credentials cannot write issues, and the job that writes issues runs no repository code, as in drift detection and the radar review.

Decision#

  1. The drift run's plan job lists every record of every zone in state, with the read-only plan role, which already reads Route 53.
  2. A record OpenTofu does not manage is drift. scripts/zone-verdict.py compares the records with the aws_route53_record resources in the plan's prior state, by zone, name and type. The only records allowed outside state are the SOA and NS records Route 53 creates at each zone's apex. Anything else turns the verdict to drift, and the drift issue names it. Anything the script cannot read is an error, never clean.
  3. The zone's history is one issue labelled zone-history, opened by the workflow. Its body is the zone as last exported, in zone-file form, sorted. The plan job, given issues: read, finds that issue and works out the difference; the report job, which already holds issues: write and runs no repository code, comments the difference and then replaces the body. An unchanged zone writes nothing, and a person's issue is never written.
  4. No new check target. The script's tests are test_zone_verdict.py, which make test-drift already runs.

Alternatives considered#

Commit each export to a branch. A history git log -p can read, but it needs contents: write in a CI job while main is unprotected, so that job could push anywhere.

A workflow artifact per run. No grant at all, but GitHub deletes artifacts after at most 90 days, so it is not a history.

Run it in dns-health, twice a day. It already holds the plan role for the alarm read, so an unmanaged record would be seen within hours rather than a week. But whether production matches main is drift detection's question, and its issue and runbook are where the answer belongs. CT already watches the most dangerous case, a certificate for a new name, twice a day.

Compare with configuration instead of state. Some names are known only once AWS has made them, such as the ACM validation and DKIM selector names, so configuration cannot list them. State holds every record OpenTofu manages, under the name it has.

Consequences#

Positive: a record created outside OpenTofu is seen within a week, by name and type, and the zone has a history of every change it served, without a new workflow, role or grant beyond issues: read on one job.

Negative:

  • A week is a long time for a hostile record. The drift run can be dispatched by hand after anything suspicious, and the runbook says so.
  • Once the repository is public, the issue lists every name in the zone, including the ACM validation and DKIM selector names, which DNSSEC's minimal denials otherwise keep from being listed. None gives an attacker anything to use: each is a CNAME to Amazon. The security posture page says so.
  • An apply that runs while the drift run exports can make a record appear unmanaged for that one run. The next run settles it.

Neutral: the rehearsal zone, while built, is exported and checked too.

Revisit when#

  • A second tool is meant to write the zone, such as an ACME client.
  • Route 53 starts creating records of its own at names other than the apex.
  • An unmanaged record is found that a week's delay made worse.

Built 2026-12-01 from commit 5f3eb2c4b04f9d8367364b6f4598a05a364e2263. This page was generated from the same source that provisions the infrastructure it describes.