| pcx_content_type | title | sidebar | head | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
how-to |
Create a secondary zone using Terraform |
|
|
A secondary 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.
- Terraform installed. Refer to Get started.
- Your Cloudflare account ID and a configured provider block. Refer to Initialize Terraform.
Create a cloudflare_zone resource with type = "secondary". The following example creates a secondary zone for subdomain.example.com:
resource "cloudflare_zone" "subdomain_example_com" {
account = {
id = var.cloudflare_account_id
}
name = "subdomain.example.com"
type = "secondary"
}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. :::