Skip to content

Zone

Source: src/Cloudflare/Zone/Zone.ts

A Cloudflare Zone (DNS domain) managed by Alchemy.

Zones default to retain on removal — destroying the stack does NOT delete the zone in Cloudflare. Opt in to actual deletion by wrapping the resource (or the whole stack) in {@link destroy}() from alchemy/RemovalPolicy.

Create a new zone

const zone = yield* Cloudflare.Zone("MyZone", {
name: "example.com",
});

Allow destruction

import { destroy } from "alchemy/RemovalPolicy";
yield* Cloudflare.Zone("MyZone", { name: "example.com" }).pipe(destroy());
import { adopt } from "alchemy/AdoptPolicy";
// A zone carries no ownership markers, so the engine refuses to take over a
// pre-existing zone unless you opt in with `adopt(true)`.
const zone = yield* Cloudflare.Zone("MyZone", {
name: "example.com",
}).pipe(adopt(true));
// zone.zoneId, zone.nameServers, zone.accountId, ...