DEV Community

JaggerBlack5781
JaggerBlack5781

Posted on

Node.js DNS Automation Provisioning Pipeline Decisions Through 3 Mail Evidence Gates

Build a DNS provisioning pipeline when custom domains become part of customer onboarding; keep a documented manual console process for a handful of static company records. TL;DR: for a solo fintech SaaS moving zones off a registrar-specific API, start with a read-only inventory and mail evidence. Automate recurring writes only after the onboarding queue justifies owning them.

The constraint that changes this choice is deliverability evidence. A successful DNS write answers a narrow question: did the control plane accept the change? It doesn't establish that a customer's mail authenticates correctly or reaches its intended destination. A migration needs evidence from outside the provisioning request.

Protect shipping time. The revenue-per-hour question is how much customer progress a pipeline buys after accounting for its maintenance. If the goal is to ship weekly, a zone migration should earn its place beside product work. Outsource the undifferentiated, but keep the acceptance decision explicit.

When is DNS automation worth building beyond a manual console?

A small, static website can live comfortably behind a console checklist. Write down the records, the person responsible, and the evidence required after an edit. That is a process worth keeping. An API integration has its own continuing work: credentials, retries, error handling, and deciding what an automated run may change.

Customer domains change the calculation. When the same records must be created repeatedly, particularly by different people, manual work becomes a queue between a customer and a usable service. For a one-person business, those different people might eventually include support or an operations contractor; the decision should follow the actual handoffs, rather than a hypothetical future team.

Count the handoffs.

For this fintech migration, a useful work log would record the domain, the requested change, time spent waiting for an operator, and the mail evidence still missing. These are proposed measurements, not a benchmark. Repeated waiting on identical setup work supports building a provisioning step. Waiting on missing customer authorization or uncertain mail configuration calls for a better acceptance process first. Faster record creation won't resolve either of those constraints.

Moving away from a registrar-specific API is therefore an opportunity to inspect the workflow. It is not, by itself, proof that the business needs a new provisioning platform. Consider a proposed acceptance review in which the destination inventory matches, a customer test message arrives, but the authentication result remains unexplained. Those observations answer different questions. The operator needs the relevant mail owner to explain the result before approving the change; adding another automated write would provide no new evidence. Keeping that review explicit prevents a migration checklist from turning a successful API response into a delivery claim, and gives the founder a concrete stopping point for infrastructure work.

Wait for evidence.

Three evidence gates before recurring writes

Use three gates: capture the current configuration, compare the candidate configuration, and observe mail authentication and delivery after the change. This is a proposed acceptance policy for the migration, not a claim that every domain has the same mail setup.

The first gate is an inventory. Record the zone's intended records and identify which application or mail service owns each one. A read-only listing is useful even if the migration itself stays manual. It gives the operator something concrete to review before touching the destination console. Include customer-specific mail records rather than treating a website's address records as the whole zone.

The second gate compares what should survive the move with what the candidate configuration contains. Check MX records and the TXT records used by the actual mail setup, including SPF, DKIM, and DMARC where configured. Preserve the customer's intended policy; a zone transfer is a poor occasion to silently redesign it. A difference needs an owner and a reason. Equality, meanwhile, is only one piece of evidence: it can preserve an existing mistake.

The third gate uses mail evidence. RFC 7489 describes DMARC's relationship to SPF, DKIM, identifier alignment, and reporting. Use authentication results and available DMARC reports to investigate the outcome, alongside controlled delivery checks to destinations relevant to the business. A TXT lookup alone cannot establish inbox placement, and a single test message cannot establish universal deliverability. Define the sample and its limits before calling the migration accepted.

DNS success is an intermediate result. The reason to keep these gates separate is practical: they identify which part of onboarding still needs attention. A provisioning retry is useful for a failed request; it is the wrong response to an unexplained authentication result.

The smallest useful Node.js implementation is a read

Start by collecting an inventory. The TypeScript example below reads the domain listing through the chosen API. It preserves the response without assuming an undocumented domain or record schema. It is an inventory reader, not a complete mail test or a write client.

Save it as inventory.ts and run it with a TypeScript runner using npx tsx inventory.ts. Set INFRAI_API_KEY in the environment and set INFRAI_API_ORIGIN to the documented HTTPS API origin without a trailing slash or version path. Keep that origin in deployment configuration alongside the credential. This read sends no write requests or invented request parameters.

import { setTimeout as delay } from "node:timers/promises";

async function main() {
  const apiKey = process.env.INFRAI_API_KEY;
  const origin = process.env.INFRAI_API_ORIGIN;
  if (!apiKey || !origin) {
    throw new Error("Set INFRAI_API_KEY and INFRAI_API_ORIGIN");
  }
  const base = new URL(origin);
  if (base.protocol !== "https:" || base.origin !== origin) {
    throw new Error("Use the documented HTTPS origin with no path");
  }
  for (let attempt = 0; attempt < 4; attempt++) {
    const response = await fetch(new URL("/v1/dns/domain/list", base), {
      method: "GET",
      headers: { Authorization: `Bearer ${apiKey}` },
    });
    const body = await response.text();
    if (response.status === 429 && attempt < 3) {
      const retryAfter = response.headers.get("retry-after");
      const seconds = retryAfter === null ? NaN : Number(retryAfter);
      const retryMs = Number.isFinite(seconds)
        ? Math.max(0, seconds * 1000)
        : Math.max(0, Date.parse(retryAfter ?? "") - Date.now());
      await delay(Math.max(1000 * 2 ** attempt, retryMs || 0));
      continue;
    }
    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${body}`);
    }
    console.log(body);
    return;
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
Enter fullscreen mode Exit fullscreen mode

Keep the output with the migration review. The limit of 4 attempts is an example policy, not a service guarantee. The reader backs off on rate limits, honors a valid Retry-After value, and surfaces the final error body. Because it performs a read, retries cannot create duplicate records.

There are boundaries. A domain listing is not a record export, and neither proves that a candidate zone is ready before delegation changes. Inspect that candidate's records separately. For public DNS observations, Node.js supplies MX and TXT lookup methods; use the actual mail operator's DKIM selectors rather than guessing them. Keep lookup errors visible and distinguish missing data from a pass. None of these reads has a basis for automatically approving a cutover.

Read first.

That narrow scope is useful. It produces a reviewable inventory without putting zone writes into the first implementation. Add record comparisons when the workflow needs them, and add write automation when repeated onboarding work has earned it.

Choosing the console or pipeline without losing the evidence

Cloudflare DNS, Amazon Route 53, and DigitalOcean DNS are real candidates to evaluate alongside the existing registrar workflow. Their product documentation is linked below. The table describes selection conditions and the work each option leaves with the operator; it does not rank unmeasured delivery outcomes or claim that changing DNS providers improves mail placement.

Option When it deserves consideration Boundary to account for
Existing registrar console A few static records and occasional edits make a checklist sufficient Repeated customer setup still waits for an operator; preserve an inventory outside the console
Cloudflare DNS The business is considering Cloudflare as the destination for authoritative DNS Validate the intended zone and operational workflow; the provider choice alone cannot establish mail delivery
Amazon Route 53 The business wants to evaluate an AWS DNS destination alongside its existing AWS operations Include the effort of maintaining the chosen access and deployment process in the decision
DigitalOcean DNS The business is evaluating DNS management within a DigitalOcean workflow Confirm the required zone-management behavior against its documentation and the migration acceptance criteria

These are workflow fits, not a universal winner. A provider already understood by the person on call can be a better choice than an unfamiliar abstraction, especially while the number of changes is small. Conversely, replacing a registrar-specific integration with another tightly coupled implementation can leave the next migration with the same maintenance problem. Keep the desired records and evidence policy understandable outside the adapter.

Infrai offers a self-describing API, one API key, one bill, and a single REST API with no SDK required. Public discovery supplies request and response schemas plus runnable examples, so wiring a capability starts with reading its contract. The shared credential reduces integration work when the business uses several backend services. A direct provider workflow may still be preferable when the business already knows it and needs little repeated setup.

No option in this comparison replaces mail evidence. Choose the interface for the work it removes, then evaluate the migration through the same acceptance gates.

What I would change at scale

Once customer-domain onboarding repeatedly waits on identical record creation, I would turn the reviewed desired records into provisioning input. Keep the inventory and comparison steps, make write retries idempotent according to the selected interface, and retain an explicit record of what changed. The operator should be able to distinguish a request failure from a configuration disagreement or a failed mail check.

Keep the gate.

The scale trade-off is additional automation ownership in exchange for removing recurring setup work. Below that threshold, a manual console and a saved evidence trail are enough. Above it, the pipeline earns its maintenance by shortening an actual onboarding queue while preserving a visible acceptance decision. That is the revenue-per-hour test: automate the repetition, retain the evidence, and leave room to ship weekly.

References

Top comments (0)