Skip to content

Create a subdomain zone using Terraform

A subdomain zone lets you manage a subdomain in a separate Cloudflare zone from the parent domain. This is useful for access control and team management. This guide shows how to automate the setup using the Cloudflare Terraform provider. It is only available for Enterprise accounts

NOTE: subdomain setup is only available for Enterprise accounts

Prerequisites

Create the zone

Create a cloudflare_zone resource for the subdomain zone. The following example creates a zone for subdomain.example.com:

resource "cloudflare_zone" "subdomain_example_com" {
account = {
id = var.cloudflare_account_id
}
name = "subdomain.example.com"
type = "full"
}

Terraform creates the zone in a Pending state. You must add NS delegation records to the parent zone before Cloudflare activates it.