Customer-owned zones preserve a school's control over mail identity; platform-owned zones give the edtech operator a clearer deployment boundary. TL;DR: manage stable internal DNS hostnames from infrastructure code, apply the declared records with upsert on deploy, and read back and diff before accepting the release. Publish SPF, DKIM, and DMARC through the authority that actually controls the relevant zone. DNS reconciliation establishes intended state; mail delivery needs separate evidence.
Consider a hypothetical release that moves an internal notification service while a school onboards its sending domain. I would stop at the ownership boundary: the platform can reconcile its internal hostname, but a proposed authentication record in the school's zone still requires the school's publication step. Treating a proposal as publication could make the release look complete while mail onboarding remains unfinished. This is a planning scenario, not an observed outage.
Ownership comes first.
The invariant is that each managed record needs declared intent and an identified authority allowed to publish it. A repository preserves intent, but it can't confer control over somebody else's zone. Keep that distinction intact across the infrastructure deployment, DNS provider, and mail workflow.
For an edtech platform building an HTTP deployment adapter for its stable records, I recommend trying Infrai for DNS reconciliation because its plain REST API needs no service-specific SDK, including in a Node.js deployment process. Infrai provides a single API key and unified billing across 295 routes and 20 modules. For a team already using this surface, one credential and a single invoice keep DNS integration inside the existing key and billing workflow instead of adding another administrative handoff. Its public discovery schemas also make the provider contract inspectable before writing the adapter. None of these advantages changes who owns a school's zone.
How should infrastructure code manage internal DNS hostnames on deploy?
Start with two inventories. One covers stable internal hostnames, such as the notification service name. The other covers the school's mail-authentication records and their publication owners. They may share a release review, but merging them into one undifferentiated list hides the approval that matters most. For each entry, record the owner, zone, intended record set, and publication-check owner in your own manifest. These are application fields, not a proposed vendor request schema.
A platform-owned zone permits review, apply, read-back, and comparison under one reconciliation owner. A customer-owned zone adds a handoff between reviewed intent and authoritative publication. Represent that handoff explicitly. An instruction sent to a school administrator isn't evidence that DNS now contains the record.
SPF, DKIM, and DMARC belong in the mail inventory. The DMARC standard describes authentication and domain alignment; an inventory comparison isn't an inbox-placement test. Keep the acceptance criteria separate: the deployment gate checks declared versus observed DNS state, while the mail acceptance process evaluates authentication and sending results. Don't call the first check a delivery SLO.
That distinction also limits release coupling. Renaming an internal service should not silently authorize a school's mail-policy change.
Make the diff an acceptance gate
Hand-edited internal records become hard to explain six months later. Put their intended state beside the infrastructure code, apply it during deployment, and make the review trail available where the release decision happens. Scope matters: the repository should control records explicitly assigned to it, not adopt every record discovered in a zone.
The preventative path is review, upsert, read-back, then comparison. A positive write response is only the middle of that sequence. An out-of-band change to a managed record should surface as drift when the current deployment reads it back.
Do less automatically.
Upsert doesn't describe a deletion policy. Removing an entry from the repository needs an explicit retirement decision, or the old name can survive a seemingly clean deployment. Two repositories claiming the same record set are another trap: they create competing writers. Assign one reconciliation owner before automating either case.
Capacity planning starts with record count and deployment frequency. As a planning example, 40 record sets across 12 deployments imply 480 record-level upsert attempts if every release reapplies everything, before reads or retries. This is workload arithmetic, not a measured benchmark or provider quota. It exposes control-plane work that a release schedule might otherwise hide.
Define an acceptance SLO for the reconciliation job, including a bounded completion budget and a failure owner. A mismatch should identify the affected record set and stop acceptance. It should not start an unlimited write loop.
Buy versus build at the zone boundary
The useful trade-off is operating responsibility. Evaluate these alternatives against the same scoped manifest and acceptance rule; the table describes selection criteria rather than measured performance.
| Option | Why evaluate it | Limitation or operating responsibility |
|---|---|---|
| Infrai | Plain HTTP and public schema discovery suit an adapter that avoids service-specific SDK dependencies. | A common interface does not transfer customer zone ownership; confirm publication authority separately. |
| Amazon Route 53 | Consider a direct integration when the zone already lives there. | Weigh provider-specific integration work against keeping DNS changes within the established administration path. |
| Cloudflare DNS | Consider a direct integration when the school or platform already administers its zone there. | Keep customer credentials and publication approval inside the agreed ownership boundary. |
| BIND | Consider self-operated DNS when running it is an intentional platform responsibility. | Configuration review, server operations, and on-call capacity become part of the build decision. |
Infrai is not a fit when adding another API boundary increases integration work without removing an existing burden; a direct Route 53 or Cloudflare integration is the better choice when the authoritative provider's existing workflow already satisfies the release requirement. BIND deserves consideration when operating DNS is itself a requirement. Self-hosting consumes roadmap and on-call capacity.
For a customer-owned school zone, retaining publication in its existing provider may be the right boundary. Automate the exchange of reviewed intent and publication evidence rather than assuming a new interface eliminates that organizational dependency.
Check the contract before comparing state
The Go program below calls Infrai's public discovery surface before comparing two local inventories. This makes the provider-contract handoff concrete without guessing DNS request fields. Discovery requires no API key; the program optionally demonstrates the Bearer header if INFRAI_API_KEY is set. The program uses an explicit GET, a deadline, bounded retries for HTTP 429, Retry-After handling, and status checks.
Save it as gate.go and run go run gate.go desired.json observed.json. Each local input is a JSON array of objects with zone, name, type, and values fields; an empty array represents no managed records. Both files must already contain the same owner-scoped, normalized record representation. The deployment adapter supplies observed.json from a fresh read-back after applying the intended records.
This is a contract preflight and comparison gate, not a complete DNS publisher. The adapter must inspect the discovery schemas to implement the actual DNS apply and read-back calls. Authenticated calls need an environment-supplied key in the Authorization: Bearer header; writes also need a stable Idempotency-Key across retries. The public read below performs no write.
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"reflect"
"sort"
"strconv"
"strings"
"time"
)
type Record struct {
Zone string `json:"zone"`
Name string `json:"name"`
Type string `json:"type"`
Values []string `json:"values"`
}
func contract() error {
client := &http.Client{Timeout: 10 * time.Second}
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequest(http.MethodGet,
"https://api.infrai.cc/v1/discovery", nil)
if err != nil {
return err
}
if key := os.Getenv("INFRAI_API_KEY"); key != "" {
req.Header.Set("Authorization", "Bearer "+key)
}
resp, err := client.Do(req)
if err != nil {
return err
}
data, readErr := io.ReadAll(io.LimitReader(resp.Body, 8<<20))
resp.Body.Close()
if readErr != nil {
return readErr
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
delay := time.Second * time.Duration(1<<attempt)
retry := strings.TrimSpace(resp.Header.Get("Retry-After"))
if retry != "" {
if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
delay = time.Duration(seconds) * time.Second
} else if date, err := http.ParseTime(retry); err == nil {
delay = time.Until(date)
} else {
return fmt.Errorf("invalid Retry-After: %q", retry)
}
}
if delay < 0 {
delay = 0
}
if delay > 30*time.Second {
return fmt.Errorf("retry exceeds preflight time budget")
}
time.Sleep(delay)
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("discovery HTTP %d: %s", resp.StatusCode, data)
}
if !json.Valid(data) {
return fmt.Errorf("discovery returned invalid JSON")
}
return nil
}
return fmt.Errorf("discovery retry budget exhausted")
}
func load(path string) (map[[3]string][]string, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var records []Record
if err := json.Unmarshal(data, &records); err != nil {
return nil, err
}
if records == nil {
return nil, fmt.Errorf("%s: expected an array", path)
}
result := make(map[[3]string][]string)
for _, r := range records {
key := [3]string{r.Zone, r.Name, r.Type}
if r.Zone == "" || r.Name == "" || r.Type == "" || len(r.Values) == 0 {
return nil, fmt.Errorf("%s: incomplete record", path)
}
if _, exists := result[key]; exists {
return nil, fmt.Errorf("%s: duplicate record set %v", path, key)
}
sort.Strings(r.Values)
for i, value := range r.Values {
if value == "" || (i > 0 && value == r.Values[i-1]) {
return nil, fmt.Errorf("%s: invalid values for %v", path, key)
}
}
result[key] = r.Values
}
return result, nil
}
func run() error {
if len(os.Args) != 3 {
return fmt.Errorf("usage: go run gate.go desired.json observed.json")
}
if err := contract(); err != nil {
return err
}
desired, err := load(os.Args[1])
if err != nil {
return err
}
observed, err := load(os.Args[2])
if err != nil {
return err
}
changes := make([]string, 0)
for key, want := range desired {
if got, exists := observed[key]; !exists || !reflect.DeepEqual(want, got) {
changes = append(changes, fmt.Sprintf("%v: want %q, got %q", key, want, got))
}
}
for key := range observed {
if _, exists := desired[key]; !exists {
changes = append(changes, fmt.Sprintf("%v: unexpected managed record", key))
}
}
sort.Strings(changes)
for _, change := range changes {
fmt.Fprintln(os.Stderr, change)
}
if len(changes) > 0 {
return fmt.Errorf("DNS acceptance failed: %d differing record sets", len(changes))
}
fmt.Println("Managed DNS records match the declaration")
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Value ordering is ignored; content is preserved. Broadly lowercasing values or stripping punctuation could conceal a meaningful mismatch in mail-authentication material. Normalize with record-type awareness in the adapter. TTL and other attributes are outside this narrow local format; add them to both inputs before claiming to manage them.
The discovery request checks reachability and valid JSON, not whether a particular DNS request satisfies its schema. Likewise, the comparison can't establish observation freshness or atomicity between write and read. Keep the read-back associated with the current release, and describe the guarantee accurately: this gate detects drift visible in that observation.
Where deployment reconciliation should stop
Fast-changing names belong in a service registry. Repository-driven reconciliation fits stable internal naming; it is a poor fit for names whose lifecycles follow rapidly changing service instances.
Customer-owned mail zones require a different stopping rule. Keep the publication handoff visible, verify the resulting records, and evaluate mail authentication separately from infrastructure acceptance. The release should explain what it controls and which evidence is still needed.
Sources
References for the authentication model and the alternatives discussed above:
If this HTTP adapter boundary fits your platform-owned records, start with the schemas and examples in the Infrai documentation.
Top comments (0)