-
Notifications
You must be signed in to change notification settings - Fork 12.9k
feat: add guide for creating partial and secondary zones in Terraform #28940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+131
−2
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3285f46
feat: add guide for creating partial and secondary zones in Terraform
musa-cf 8a8fcc8
chore: add normal partial zone creation flow
musa-cf 9fc6417
chore: use 'subdomain' consistently in Terraform guide
musa-cf d2233f5
chore: use 'subdomain' consistently in Terraform guide
musa-cf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Create a partial zone using Terraform | ||
| sidebar: | ||
| order: 1 | ||
| label: Create a partial zone | ||
| head: | ||
| - tag: title | ||
| content: Create a partial zone using Terraform | ||
| --- | ||
|
|
||
| import { Tabs, TabItem } from "~/components"; | ||
|
|
||
| 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). | ||
|
|
||
| :::caution | ||
| A partial zone cannot be created in the same Cloudflare account as the parent domain's full zone. | ||
| ::: | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Terraform installed. Refer to [Get started](/terraform/installing/). | ||
| - Your Cloudflare account ID and a configured provider block. Refer to [Initialize Terraform](/terraform/tutorial/initialize-terraform/). | ||
|
|
||
| ## Create the zone | ||
|
|
||
| Add the zone configuration and apply the change to create the zone: | ||
|
|
||
| ```hcl | ||
| resource "cloudflare_zone" "subdomain_example_com" { | ||
| account = { | ||
| id = var.cloudflare_account_id | ||
| } | ||
| name = "subdomain.example.com" | ||
| } | ||
| ``` | ||
|
|
||
| Then, in a new Terraform plan and apply cycle, upgrade the zone to a Business plan or higher: | ||
| ```hcl | ||
| resource "cloudflare_zone_subscription" "example_zone_subscription" { | ||
| zone_id = cloudflare_zone.subdomain_example_com.id | ||
| frequency = "monthly" | ||
| rate_plan = { | ||
| id = "business" | ||
| currency = "USD" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Then, again in a new Terraform plan and apply cycle, update your Terraform configuration to add `type = "partial"` to the zone: | ||
|
|
||
| ```hcl | ||
| resource "cloudflare_zone" "subdomain_example_com" { | ||
| account = { | ||
| id = var.cloudflare_account_id | ||
| } | ||
| name = "subdomain.example.com" | ||
| type = "partial" | ||
| } | ||
| ``` | ||
|
|
||
| Terraform places the zone in a **Pending** state. You must add the necessary DNS records and verify domain ownership before Cloudflare activates it. | ||
|
|
||
| :::note | ||
| 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. | ||
| ::: | ||
|
|
||
| ## Related resources | ||
|
|
||
| - [Partial zone setup](/dns/zone-setups/partial-setup/) | ||
| - [Convert a full zone to partial](/dns/zone-setups/conversions/convert-full-to-partial/) | ||
| - [`cloudflare_zone` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone) |
43 changes: 43 additions & 0 deletions
43
src/content/docs/terraform/how-to/create-secondary-zone.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Create a secondary zone using Terraform | ||
| sidebar: | ||
| order: 2 | ||
| label: Create a secondary zone | ||
musa-cf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| head: | ||
| - tag: title | ||
| content: Create a secondary zone using Terraform | ||
musa-cf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| A [secondary zone](/dns/zone-setups/subdomain-setup/) 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](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs). | ||
musa-cf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
musa-cf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ## Prerequisites | ||
|
|
||
| - Terraform installed. Refer to [Get started](/terraform/installing/). | ||
| - Your Cloudflare account ID and a configured provider block. Refer to [Initialize Terraform](/terraform/tutorial/initialize-terraform/). | ||
|
|
||
| ## Create the zone | ||
|
|
||
| Create a `cloudflare_zone` resource with `type = "secondary"`. The following example creates a secondary zone for `subdomain.example.com`: | ||
musa-cf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```hcl | ||
| resource "cloudflare_zone" "subdomain_example_com" { | ||
| account = { | ||
| id = var.cloudflare_account_id | ||
| } | ||
| name = "subdomain.example.com" | ||
| type = "secondary" | ||
musa-cf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ``` | ||
|
|
||
| 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](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone) in the Terraform provider documentation when you need to reference other zone properties. | ||
| ::: | ||
|
|
||
| ## Related resources | ||
|
|
||
| - [Subdomain setup](/dns/zone-setups/subdomain-setup/) | ||
| - [`cloudflare_zone` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zone) | ||
| - [`cloudflare_dns_record` resource](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/dns_record) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| pcx_content_type: navigation | ||
| title: How-to guides | ||
| sidebar: | ||
| order: 5 | ||
| group: | ||
| hideIndex: true | ||
| --- | ||
|
|
||
| import { DirectoryListing } from "~/components"; | ||
|
|
||
| The following guides explain how to complete common Terraform tasks. | ||
|
|
||
| <DirectoryListing /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.