Skip to main content

Manage Cloudflare DNS records

Manage Cloudflare DNS records on a zone

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set cloudflare-ts-dns
cd pulumi-examples/cloudflare-ts-dns

Manages a set of DNS records on a Cloudflare zone — an A record, a CNAME, and a TXT record.

Prerequisites#

  1. Install Pulumi

  2. Install Node.js

  3. A domain already added to Cloudflare as a zone.

  4. Create a Cloudflare API token with DNS edit permissions, and export it:

    Terminal window
    export CLOUDFLARE_API_TOKEN=<your-token>

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Set the zone to manage (find the zone ID on your domain’s overview page in the Cloudflare dashboard):

    Terminal window
    pulumi config set zoneId <your-zone-id>
  3. Install dependencies and deploy:

    Terminal window
    npm install
    pulumi up
  4. Inspect the created records:

    Terminal window
    pulumi stack output records

Cleaning up#

Terminal window
pulumi destroy
pulumi stack rm dev

Related

The infrastructure as code platform for any cloud.