Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/docs/terraform/advanced-topics/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pcx_content_type: navigation
title: Advanced topics
sidebar:
order: 5
order: 6
group:
hideIndex: true
---
Expand Down
72 changes: 72 additions & 0 deletions src/content/docs/terraform/how-to/create-partial-zone.mdx
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 src/content/docs/terraform/how-to/create-secondary-zone.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
pcx_content_type: how-to
title: Create a subdomain zone using Terraform
sidebar:
order: 2
label: Create a subdomain zone
head:
- tag: title
content: Create a subdomain zone using Terraform
---

A [subdomain 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). It is only available for Enterprise accounts
> NOTE: subdomain setup is only available for Enterprise accounts
## 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 for the subdomain zone. The following example creates a zone for `subdomain.example.com`:

```hcl
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](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)
14 changes: 14 additions & 0 deletions src/content/docs/terraform/how-to/index.mdx
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 />
2 changes: 1 addition & 1 deletion src/content/docs/terraform/troubleshooting/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pcx_content_type: navigation
title: Troubleshooting
sidebar:
order: 6
order: 7
group:
hideIndex: true
---
Expand Down
Loading