Create a subdomain zone using Terraform

Last updated Apr 21, 2026 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.

Note

Refer to the cloudflare_zone docs ↗︎ in the Terraform provider documentation when you need to reference other zone properties.

Was this helpful?

YesNo

On this page

Create a subdomain zone using Terraform - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/terraform/how-to/create-secondary-zone/#page","headline":"Create a subdomain zone using Terraform","description":"Automate the setup of a Cloudflare subdomain zone for Enterprise accounts using Terraform.","url":"https://developers.cloudflare.com/terraform/how-to/create-secondary-zone/","inLanguage":"en","image":"https://developers.cloudflare.com/terraform/how-to/create-secondary-zone/og.png?v=ef45add96f9523a2","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Recommended directory structure, state management, and workflow practices for Cloudflare Terraform. title: Best practices image: https://developers.cloudflare.com/terraform/advanced-topics/best-practices/og.png?v=667da80310f1ae7e


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/terraform/llms.txt
Use this file to discover all available pages before exploring further.