| pcx_content_type | how-to | |||||
|---|---|---|---|---|---|---|
| title | Create a subdomain zone using Terraform | |||||
| sidebar |
|
|||||
| head |
|
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
- Terraform installed. Refer to Get started.
- Your Cloudflare account ID and a configured provider block. Refer to Initialize Terraform.
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. :::