---
title: "Manage Cloudflare DNS records"
description: "Manage Cloudflare DNS records on a zone"
url: "https://www.pulumi.com/dev/examples/cloudflare-ts-dns/"
image: "https://www.pulumi.com/assets/og/dev/examples/cloudflare-ts-dns.png"
---

# Manage Cloudflare DNS records

Manage Cloudflare DNS records on a zone

- Source on GitHub: https://github.com/pulumi/examples/tree/master/cloudflare-ts-dns
- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Fexamples%2Ftree%2Fmaster%2Fcloudflare-ts-dns

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/cloudflare-ts-dns) repo. Pull down just this directory to follow along:

```bash
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](https://developers.cloudflare.com/dns/manage-dns-records/) on a
Cloudflare zone — an `A` record, a `CNAME`, and a `TXT` record.

## Prerequisites

1. [Install Pulumi](https://www.pulumi.com/docs/install/)
1. [Install Node.js](https://www.pulumi.com/docs/iac/languages-sdks/javascript/)
1. A domain already added to Cloudflare as a [zone](https://developers.cloudflare.com/dns/zone-setups/).
1. Create a [Cloudflare API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/)
   with DNS edit permissions, and export it:

   ```bash
   export CLOUDFLARE_API_TOKEN=<your-token>
   ```

## Deploying the example

1.  Create a new stack:

    ```bash
    pulumi stack init dev
    ```

1.  Set the zone to manage (find the zone ID on your domain's overview page in the Cloudflare dashboard):

    ```bash
    pulumi config set zoneId <your-zone-id>
    ```

1.  Install dependencies and deploy:

    ```bash
    npm install
    pulumi up
    ```

1.  Inspect the created records:

    ```bash
    pulumi stack output records
    ```

## Cleaning up

```bash
pulumi destroy
pulumi stack rm dev
```
