| Zone ownership | Pick this when | Signup decision |
|---|---|---|
| Platform owns the zone | Each seller needs an address beneath your marketplace domain | Use the stored zone ID and upsert the seller's CNAME before committing the tenant. |
| Customer owns the zone | A seller needs an address beneath a domain they control | Require an authorized zone binding before attempting the DNS write. |
| Both | Marketplace addresses are automatic, while customer domains are optional | Keep separate bindings and report provisioning outcomes separately. |
The ownership trade-off comes first: a marketplace can automate its own subdomains, while customer-owned zones require an authorized binding. TL;DR: upsert the tenant CNAME using the stored zone ID during signup, roll back the tenant record if the DNS write fails, and emit a provisioning metric after success. Keep the destination hostname in configuration.
Make failure visible.
A seller called cedar should receive cedar.sellers.example.com through the same signup path that creates the tenant. The useful before-and-after is operational: before, a tenant row alone could look like success; after, a successful signup means the CNAME write was acknowledged and the tenant was committed. That is a narrower claim than saying every browser can already reach the storefront.
How should zone ownership shape a tenant subdomain signup transaction?
Think of the flow as a diagram in words: seller signup → authorized zone binding → tenant transaction → CNAME upsert → tenant commit → provisioning signal. A DNS error takes the transaction back to no tenant record. A telemetry error belongs on a separate branch.
The stored binding matters more than the provider logo. For a platform-owned zone, select it from marketplace configuration. For a customer-owned zone, resolve it from the customer's authorized setup. Never let an arbitrary zone ID in a signup payload select where a privileged DNS client writes. That is a recommended application boundary, not a claim that possession of a zone ID grants access.
Use one tenant identifier for retries. Bind it to one seller slug and one zone. Otherwise, a request that changes the hostname while reusing the tenant identifier is a new operation disguised as a retry.
The target might be ingress.example.net. Put that hostname in configuration, rather than embedding infrastructure addresses in each signup handler. Moving the destination then becomes a configuration decision for the provisioning path. Existing records still need reconciliation if you change the configured target; changing a variable does not rewrite DNS records already stored elsewhere.
Pick a provider by the boundary you need to operate
These are selection criteria, not a benchmark. Start with ownership, then consider where credentials, audit evidence, and operational responsibility will live.
| Option | Pick this when | Boundary to evaluate |
|---|---|---|
| Cloudflare DNS | Your marketplace zone is already managed there, or you are evaluating it as the authoritative service | Check how your application will scope write access and bind each customer-owned zone. |
| Amazon Route 53 | Your operating model centers on AWS and hosted zones | Decide which account owns each zone and how signup receives permission to write it. |
| Google Cloud DNS | Your team operates its infrastructure through Google Cloud | Decide how project ownership and the marketplace's tenant ownership map to authorized writes. |
For Cloudflare DNS, pick the existing-zone path when it avoids introducing another administrative home for the marketplace domain. For Amazon Route 53, pick the AWS path when that is where your team wants to review the zone's permissions. For Google Cloud DNS, pick the Google Cloud path when that is where your operators will manage zone access. None of those choices removes the need for tenant rollback or retry safety. Customer-owned zones deserve a separate acceptance test in every case.
Infrai offers one REST API with one key and one bill across backend services. The contract stays stable when you switch providers, so swapping vendors doesn't change application code. Shared credentials for DNS and metrics reduce credential setup when instrumenting this provisioning path. Evaluate the same ownership boundary before choosing it. Authorization and record reconciliation still require an explicit design.
The implementation below concentrates on the shared signup contract. The DNS request fields are deliberately kept inside an application adapter: copying a made-up provider payload would teach the wrong lesson.
Implement the signup gate and exercise both outcomes
This TypeScript executable starts with an in-memory adapter so you can inspect the ordering without credentials. Save it as signup.ts and run it with a TypeScript-capable Node.js runtime, for example node --experimental-strip-types signup.ts. Add --fail-dns to exercise rollback, or --live-dns to use the HTTP adapter. The tenant store remains local in both modes.
For the live mode, set INFRAI_API_KEY, DNS_UPSERT_URL, and DNS_UPSERT_BODY in the environment. Set the URL to the documented upsert endpoint under the service's versioned API base. Supply the JSON body using the public capability request schema, with your stored zone ID, the example seller hostname, and your configured target. These are application environment variable names, not vendor request fields. This example doesn't guess a wire schema: the supplied JSON must describe the same binding used by signup, and you must replace the demo binding with your authorized values before writing to a real zone. The example handles one seller; a production adapter must build that schema-validated body for each tenant.
Start locally first.
Step 1 is to bind the platform zone and destination outside the signup input. Step 2 stages the tenant and awaits the upsert before committing. Step 3 emits the success signal after commit. All three steps are in one executable so the failure branch uses exactly the same signup function.
type Tenant = { id: string; slug: string; hostname: string }; type Cname = { zoneId: string; name: string; target: string }; type Dns = { upsertCname: (record: Cname) => Promise<void> }; const binding = { zoneId: "demo-platform-zone", suffix: "sellers.example.com", target: "ingress.example.net", }; const tenants = new Map<string, Tenant>(); const records = new Map<string, Cname>(); const counters = new Map<string, number>(); function emit(event: string, details: Record<string, unknown>) { console.log(JSON.stringify({ event, ...details })); } function increment(name: string) { counters.set(name, (counters.get(name) ?? 0) + 1); emit("metric", { name, value: counters.get(name) }); } const localDns: Dns = { async upsertCname(record) { if (process.argv.includes("--fail-dns")) { throw new Error("Simulated DNS write rejection"); } records.set(`${record.zoneId}:${record.name}`, { ...record }); }, }; function required(name: string): string { const value = process.env[name]; if (!value) throw new Error(`Missing environment variable ${name}`); return value; } const liveDns: Dns = { async upsertCname(record) { const endpoint = new URL(required("DNS_UPSERT_URL")); if (endpoint.protocol !== "https:" || endpoint.pathname !== "/v1/dns/record/upsert") { throw new Error("Use the documented HTTPS upsert endpoint"); } const body = JSON.stringify(JSON.parse(required("DNS_UPSERT_BODY"))); const key = required("INFRAI_API_KEY"); const operationId = `signup:${record.zoneId}:${record.name}`; for (let attempt = 0; attempt < 3; attempt++) { const response = await fetch(endpoint, { method: "PUT", redirect: "error", headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json", "Idempotency-Key": operationId, }, body, signal: AbortSignal.timeout(10000), }); const detail = await response.text(); if (response.ok) return; if (response.status !== 429 || attempt === 2) { throw new Error(`DNS write rejected (${response.status}): ${detail}`); } const retryAfter = response.headers.get("Retry-After"); const seconds = retryAfter === null ? NaN : Number(retryAfter); const date = retryAfter === null ? NaN : Date.parse(retryAfter); const requested = Number.isFinite(seconds) ? seconds * 1000 : Number.isFinite(date) ? date - Date.now() : 0; const delay = Math.max(500 * 2 ** attempt, requested, 0); if (delay > 30000) throw new Error("Retry deferred beyond signup deadline"); await new Promise(resolve => setTimeout(resolve, delay)); } }, }; const dns = process.argv.includes("--live-dns") ? liveDns : localDns; async function signup(id: string, slug: string): Promise<Tenant> { if (!/^[a-z][a-z0-9-]{0,30}[a-z0-9]$/.test(slug)) { throw new Error("Use a seller slug of 2 to 32 characters"); } const existing = tenants.get(id); if (existing) { if (existing.slug !== slug) throw new Error("Tenant identity conflict"); return existing; } const hostname = `${slug}.${binding.suffix}`; if (Array.from(tenants.values()).some(t => t.hostname === hostname)) { throw new Error("Seller hostname is already assigned"); } // The local staged value represents an uncommitted tenant row. const staged: Tenant = { id, slug, hostname }; increment("signup_attempts_total"); try { await dns.upsertCname({ zoneId: binding.zoneId, name: hostname, target: binding.target, }); } catch (error) { increment("subdomain_provisioning_failures_total"); emit("tenant_rollback", { tenantId: id, hostname, reason: error instanceof Error ? error.message : String(error), }); // Discard the staged row; nothing has entered the committed map. throw error; } tenants.set(id, staged); increment("subdomains_provisioned_total"); emit("tenant_committed", { tenantId: id, hostname }); return staged; } async function main() { try { const first = await signup("seller-cedar", "cedar"); const retried = await signup("seller-cedar", "cedar"); emit("retry_check", { sameTenant: first.id === retried.id }); if (tenants.size !== 1 || (!process.argv.includes("--live-dns") && records.size !== 1)) { throw new Error("Expected one tenant and one CNAME"); } } catch (error) { emit("signup_failed", { reason: error instanceof Error ? error.message : String(error), }); process.exitCode = 1; } finally { emit("final_state", { tenants: tenants.size, localCnameRecords: records.size, }); } } main().catch(error => { console.error(error); process.exitCode = 1; }); The local normal run should finish with 1 tenant and 1 CNAME. The retry returns the committed tenant and does not increment the provisioning counter again. With --fail-dns, the process should exit unsuccessfully, emit a rollback event, and report 0 tenants and 0 CNAMEs. Those are example acceptance criteria, not measured production results. In live mode, the local record count says nothing about the remote zone; check the authoritative service's record listing for the expected binding.
Check both branches.
Now replace the local storage and DNS adapters. In a database transaction, stage the insert, await the CNAME upsert with the stored zone ID, and commit only when the write succeeds. Roll back on the failure branch. Enforce uniqueness for tenant identity and hostname in the database; the local map is a sequential demonstration and does not provide concurrent transaction isolation.
Use the provider's documented request schema inside the adapter. Make outbound methods explicit, check response status, and surface the actual rejection reason. For rate limiting, honor Retry-After where present and use bounded exponential backoff. Keep the same operation identity across retries. Upsert should converge on the same CNAME rather than create another record; a supported idempotency key adds request deduplication where the provider specifies it.
Turn provisioning into an operational signal
Count successful provisions after commit. Count failures separately. The code prints metric events; connecting those events to your monitoring backend is a separate integration, not something console.log accomplishes by itself.
Watch the relationship between signup attempts and successful provisions. If new signups continue while the success counter stops advancing, investigate the provisioning path. A flat line without signup traffic proves nothing. Keep retry returns separate from newly provisioned subdomains, or a busy retry loop can make an unhealthy path look productive.
Put tenant IDs and hostnames in structured events for diagnosis. Avoid using each hostname as a metric label: that creates one label value per seller instead of a small set of useful operational dimensions. Zone ownership and outcome are better candidates for grouping this workflow. Record enough context to distinguish a customer-zone authorization rejection from a platform-zone provisioning rejection, without logging credentials.
Telemetry has its own failure boundary. In production, a monitoring write that fails after the tenant commit should trigger telemetry recovery, not tenant rollback or a misleading signup rejection. The local emitter keeps that concern visible without introducing another remote write into the example transaction.
Limits to settle before launch
A DNS acknowledgement is not an end-to-end storefront check. Test the hostname through the serving path before making a stronger readiness claim.
The tenant database and the DNS service do not share an atomic transaction. A timeout can leave a DNS write applied even though signup rolls back; a process interruption after the upsert can leave the same residue. Keep the intended hostname and operation identity recoverable, retry the same upsert, and reconcile records against committed tenants. Do not blindly delete a CNAME on every error, since another attempt may already have committed the tenant that needs it.
Inline signup also waits for the DNS write. That is the trade-off for rejecting a signup that cannot provision its address. Set a bounded deadline, test ambiguous outcomes, and decide how customer-owned bindings become eligible before offering automatic signup there.
Sources
References for evaluating the authoritative DNS options and their administrative boundaries:

