Skip to content

Commit 8a8fcc8

Browse files
committed
chore: add normal partial zone creation flow
1 parent 3285f46 commit 8a8fcc8

File tree

2 files changed

+25
-56
lines changed

2 files changed

+25
-56
lines changed

src/content/docs/terraform/how-to/create-partial-zone.mdx

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ head:
99
content: Create a partial zone using Terraform
1010
---
1111

12+
import { Tabs, TabItem } from "~/components";
13+
1214
A [partial zone](/dns/zone-setups/partial-setup/) lets you use Cloudflare for a subdomain while keeping your existing authoritative DNS provider for the parent domain. This guide shows how to automate the setup using the [Cloudflare Terraform provider](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs).
1315

1416
:::caution
@@ -19,66 +21,52 @@ A partial zone cannot be created in the same Cloudflare account as the parent do
1921

2022
- Terraform installed. Refer to [Get started](/terraform/installing/).
2123
- Your Cloudflare account ID and a configured provider block. Refer to [Initialize Terraform](/terraform/tutorial/initialize-terraform/).
22-
- Partial zone entitlement enabled on your account. Contact your Cloudflare account team to confirm.
2324

24-
## 1. Create the zone
25+
## Create the zone
2526

26-
Create a `cloudflare_zone` resource with `type = "partial"`. The following example creates a partial zone for `subdomain.example.com`:
27+
Add the zone configuration and apply the change to create the zone:
2728

2829
```hcl
2930
resource "cloudflare_zone" "subdomain_example_com" {
3031
account = {
3132
id = var.cloudflare_account_id
3233
}
3334
name = "subdomain.example.com"
34-
type = "partial"
3535
}
3636
```
3737

38-
Terraform creates the zone in a **Pending** state. You must verify domain ownership before Cloudflare activates it.
39-
40-
## 2. Verify domain ownership
41-
42-
Create a `TXT` record in your authoritative DNS provider using the `verification_key` output from the zone resource. The record name follows the pattern `cloudflare-verify.<your-subdomain>`.
43-
44-
The syntax for this record varies by DNS provider. The following example uses a generic `dns_record` resource:
45-
38+
Then, in a new Terraform plan and apply cycle, upgrade the zone to a Business plan or higher:
4639
```hcl
47-
# This record belongs to the parent domain zone
48-
resource "dns_record" "subdomain_verification" {
49-
zone_id = var.parent_zone_id
50-
type = "TXT"
51-
name = "cloudflare-verify.subdomain.example.com"
52-
content = cloudflare_zone.subdomain_example_com.verification_key
53-
ttl = 1
40+
resource "cloudflare_zone_subscription" "example_zone_subscription" {
41+
zone_id = cloudflare_zone.subdomain_example_com.id
42+
frequency = "monthly"
43+
rate_plan = {
44+
id = "business"
45+
currency = "USD"
46+
}
5447
}
5548
```
5649

57-
## 3. Add CNAME delegation
58-
59-
Delegate DNS for the subdomain to Cloudflare using a `CNAME` record. The target follows the pattern `<hostname>.cdn.cloudflare.net`.
60-
61-
As with the verification record, the syntax varies by DNS provider:
50+
Then, again in a new Terraform plan and apply cycle, update your Terraform configuration to add `type = "partial"` to the zone:
6251

6352
```hcl
64-
# This record belongs to the parent domain zone
65-
resource "dns_record" "subdomain_cname" {
66-
zone_id = var.parent_zone_id
67-
type = "CNAME"
68-
name = "subdomain.example.com"
69-
content = "subdomain.example.com.cdn.cloudflare.net"
70-
ttl = 1
53+
resource "cloudflare_zone" "subdomain_example_com" {
54+
account = {
55+
id = var.cloudflare_account_id
56+
}
57+
name = "subdomain.example.com"
58+
type = "partial"
7159
}
7260
```
7361

74-
After applying your configuration, allow time for DNS propagation before the zone becomes active.
62+
Terraform places the zone in a **Pending** state. You must add the necessary DNS records and verify domain ownership before Cloudflare activates it.
7563

7664
:::note
77-
Refer to the [read-only zone outputs](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone#read-only) in the Terraform provider documentation when you need to reference other zone properties.
65+
Refer to the [cloudflare_zone docs](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone) in the Terraform provider documentation when you need to reference other zone properties.
7866
:::
7967

8068
## Related resources
8169

8270
- [Partial zone setup](/dns/zone-setups/partial-setup/)
8371
- [Convert a full zone to partial](/dns/zone-setups/conversions/convert-full-to-partial/)
84-
- [`cloudflare_zone` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone)
72+
- [`cloudflare_zone` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone)

src/content/docs/terraform/how-to/create-secondary-zone.mdx

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ A [secondary zone](/dns/zone-setups/subdomain-setup/) lets you manage a subdomai
1515

1616
- Terraform installed. Refer to [Get started](/terraform/installing/).
1717
- Your Cloudflare account ID and a configured provider block. Refer to [Initialize Terraform](/terraform/tutorial/initialize-terraform/).
18-
- Secondary zone entitlement enabled on your account. Contact your Cloudflare account team to confirm.
1918

20-
## 1. Create the zone
19+
## Create the zone
2120

2221
Create a `cloudflare_zone` resource with `type = "secondary"`. The following example creates a secondary zone for `subdomain.example.com`:
2322

@@ -33,30 +32,12 @@ resource "cloudflare_zone" "subdomain_example_com" {
3332

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

36-
## 2. Add NS delegation records
37-
38-
Create `NS` records in the parent zone that delegate authority to the new secondary zone. Use the `name_servers` output from the zone resource to populate the record values:
39-
40-
```hcl
41-
resource "cloudflare_dns_record" "subdomain_example_com_ns" {
42-
for_each = toset(cloudflare_zone.subdomain_example_com.name_servers)
43-
44-
zone_id = cloudflare_zone.example_com.id
45-
type = "NS"
46-
name = "subdomain.example.com"
47-
content = each.value
48-
ttl = 1
49-
}
50-
```
51-
52-
After applying your configuration, allow time for DNS propagation before the zone becomes active.
53-
5435
:::note
55-
Refer to the [read-only zone outputs](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone#read-only) in the Terraform provider documentation when you need to reference other zone properties.
36+
Refer to the [cloudflare_zone docs](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone) in the Terraform provider documentation when you need to reference other zone properties.
5637
:::
5738

5839
## Related resources
5940

6041
- [Subdomain setup](/dns/zone-setups/subdomain-setup/)
6142
- [`cloudflare_zone` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone)
62-
- [`cloudflare_dns_record` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/dns_record)
43+
- [`cloudflare_dns_record` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/dns_record)

0 commit comments

Comments
 (0)