Repository navigation
feat(dns): retire DNS records only through a reviewed list - #91
Conversation
The guarded DNS apply refused every delete, so a reviewed change could not remove a DNS record, such as the second iCloud MX record the company Email cutover retires (devantler-tech/platform#5481). Add .github/dns-retirements.json, committed empty. Each entry names one record by address, name, type and current content; at most 20 entries with unique addresses, and a malformed list refuses every run, like the handover list. scripts/assert-no-destructive-plan.sh takes the list as an optional second argument and then admits only a pure delete of a managed DNS record that matches its entry, reporting how many it admitted. Without the argument it behaves exactly as before. scripts/check-dns-plan.jq takes the list as $retirements and admits ["delete"] only for a matching record that external-dns does not own. Replacements, unlisted deletes and deletes of anything but a DNS record stay refused. scripts/apply-dns.sh checks the file like the handover list and passes it to both guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai review |
Action performed
|
|
No actionable comments were generated in the recent review.
|
|
Ready at
🤖 Generated with Claude Code |
Verified signed merge I also ran the retirement guard and DNS apply fixture suites from the merged source. They rejected unlisted deletions and replacements and accepted the reviewed retirement fixture. The merged retirement list is empty. These checks exercised the guard with fixtures. Any live retirement requires its own reviewed list and protected apply. |
Why
Company mail moves its MX from iCloud to the platform's mail server (devantler-tech/platform#5481). The cutover changes
mail_mx_01tomail.devantler.tech, an in-place update the guards already allow, and must removemail_mx_02. The guarded DNS apply refuses every delete today:assert-no-destructive-plan.shrejects anydeleteaction, andcheck-dns-plan.jqadmits only no-op, create, update and forget. AGENTS.md anticipates reviewed DNS replacements once the import migration is complete, and it is.What
.github/dns-retirements.json, committed empty. A deletion is admitted only for a pure["delete"]of a managedcloudflare_dns_recordthat meets all of these:Replacements (
delete,createorcreate,delete) stay refused even when listed. The zone, buckets, zone settings and every other resource type can never be deleted.List rules: at most 20 entries, each with exactly
address,name,typeandcontent, and no duplicate addresses. Addresses must becloudflare_dns_record.<id>. Types must beA,AAAA,CNAME,MXorTXT. A malformed list fails the plan, as the handover list already does.Guards:
assert-no-destructive-plan.shtakes the list as an optional second argument; without it, behaviour and output are unchanged.check-dns-plan.jqtakes it as--slurpfile retirements.apply-dns.shchecks the file the way it checks the handover list and passes it to both. The state-bootstrap scripts still call the guard without it.Docs: AGENTS.md, the README and the runbook say deletes happen only through this list. Each entry is added in the change that removes its record from
dns.tfand removed once the deletion is applied.This change deletes nothing. The cutover PR will add the
mail_mx_02entry together with thedns.tfedit.Validation
shellcheckis clean.test-no-destructive-plan.shpasses undershanddash, andtest-dns-apply.shpasses. Cases covered:tofu fmt -check,tofu init -backend=false,tofu validateandtofu testpass.test-native-state-migration.shandnative-s3-migration_test.goneed OpenTofu exactly 1.12.6, which the local host lacks. They fail the same way on unmodifiedmainand cover a migration script this change does not touch. CI pins 1.12.6.Separate note:
.terraform.lock.hclonmainstill saysconstraints = "5.28.1"for the locked 5.29.0, a leftover from #90. A read-onlytofu initaccepts it. It deserves its own one-line fix.Part of devantler-tech/platform#5481.
🤖 Generated with Claude Code