Skip to content

Commit 64806b7

Browse files
authored
[WAF, Terraform] Improve Terraform info and links from/to the WAF (#19681)
Also adds some Terraform links to Rules features
1 parent be1d079 commit 64806b7

File tree

30 files changed

+156
-56
lines changed

30 files changed

+156
-56
lines changed

src/content/docs/rules/transform/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Alternatively, create a transform rule from scratch in the dashboard or via Clou
3737
- [HTTP response header modification rules](/rules/transform/response-header-modification/create-dashboard/)
3838
- [Managed Transforms](/rules/transform/managed-transforms/)
3939

40+
For Terraform examples, refer to [Transform Rules configuration using Terraform](/terraform/additional-configurations/transform-rules/).
41+
4042
Refer to [Rules language](/ruleset-engine/rules-language/) for more information on building expressions for Transform Rules.
4143

4244
## Availability

src/content/docs/rules/transform/managed-transforms/configure.mdx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ head: []
77
description: Learn how to configure Managed Transforms.
88
---
99

10-
import { Details, TabItem, Tabs } from "~/components";
10+
import { Details, TabItem, Tabs, Render } from "~/components";
1111

12-
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
12+
<Tabs syncKey="dashPlusAPIPlusTerraform"> <TabItem label="Dashboard">
1313

1414
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account and website.
1515

@@ -182,4 +182,28 @@ The response will include all the available Managed Transforms and their new sta
182182

183183
</Details>
184184

185+
</TabItem> <TabItem label="Terraform">
186+
187+
<Render file="v4-code-snippets" product="terraform" />
188+
189+
Use the `cloudflare_managed_headers` Terraform resource to configure Managed Transforms. For example:
190+
191+
```tf
192+
resource "cloudflare_managed_headers" "tf_example" {
193+
zone_id = "<ZONE_ID>"
194+
195+
managed_request_headers {
196+
id = "add_visitor_location_headers"
197+
enabled = true
198+
}
199+
200+
managed_response_headers {
201+
id = "remove_x-powered-by_header"
202+
enabled = true
203+
}
204+
}
205+
```
206+
207+
Make sure you include the Managed Transforms you are updating in the correct object (`managed_request_headers` or `managed_response_headers`).
208+
185209
</TabItem> </Tabs>

src/content/docs/rules/transform/managed-transforms/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Managed Transforms allow you to perform common adjustments to HTTP request and r
1515

1616
For a complete list, refer to [Available Managed Transforms](/rules/transform/managed-transforms/reference/).
1717

18-
When you enable a Managed Transform, Cloudflare internally deploys one or more Transform Rules to handle the common configuration you selected. These generated rules will not count against the maximum number of Transform Rules available in your Cloudflare plan.
18+
When you enable a Managed Transform, Cloudflare internally deploys one or more Transform Rules to handle the common configuration you selected. These generated rules will not count against the [maximum number of Transform Rules](/rules/transform/#availability) available in your Cloudflare plan.
1919

2020
Enabled Managed Transforms will apply to all inbound requests for the zone.
2121

@@ -25,4 +25,4 @@ The generated internal Transform Rules will not appear in the Transform Rules li
2525

2626
## Next steps
2727

28-
For dashboard and API instructions, refer to [Configure Managed Transforms](/rules/transform/managed-transforms/configure/).
28+
For dashboard, API, and Terraform instructions, refer to [Configure Managed Transforms](/rules/transform/managed-transforms/configure/).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
pcx_content_type: navigation
3+
title: Create a rule using Terraform
4+
external_link: /terraform/additional-configurations/transform-rules/#create-an-http-request-header-modification-rule
5+
sidebar:
6+
order: 4
7+
---
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
pcx_content_type: navigation
3+
title: Create a rule using Terraform
4+
external_link: /terraform/additional-configurations/transform-rules/#create-an-http-response-header-modification-rule
5+
sidebar:
6+
order: 4
7+
---

src/content/docs/rules/transform/url-rewrite/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Rewrite URL rules can perform static or dynamic rewrites:
3333
- **Static rewrite**: Replaces a given part of a request URL (path or query string) with a static string.
3434
- **Dynamic rewrite**: Supports more advanced scenarios where you use a rewrite expression to define the resulting path or query string.
3535

36-
Create rewrite URL rules [in the dashboard](/rules/transform/url-rewrite/create-dashboard/) or [via API](/rules/transform/url-rewrite/create-api/).
36+
Create rewrite URL rules [in the dashboard](/rules/transform/url-rewrite/create-dashboard/), [via Cloudflare API](/rules/transform/url-rewrite/create-api/), or [using Terraform](/terraform/additional-configurations/transform-rules/#create-a-rewrite-url-rule).
3737

3838
## Serve images from custom paths
3939

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
pcx_content_type: navigation
3+
title: Create a rule using Terraform
4+
external_link: /terraform/additional-configurations/transform-rules/#create-a-rewrite-url-rule
5+
sidebar:
6+
order: 4
7+
---

src/content/docs/terraform/additional-configurations/ddos-managed-rulesets.mdx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
---
2-
title: DDoS managed rulesets
2+
title: DDoS managed rulesets configuration using Terraform
33
pcx_content_type: how-to
44
sidebar:
55
order: 3
6+
label: DDoS managed rulesets
67
head:
78
- tag: title
8-
content: Configure DDoS managed rulesets with Terraform
9+
content: DDoS managed rulesets configuration using Terraform
910
---
1011

11-
import { Render } from "~/components";
12+
import { Render, RuleID } from "~/components";
1213

13-
This page provides examples of configuring DDoS managed rulesets in your zone or account using Terraform. It covers the following configurations:
14+
This page provides examples of configuring [DDoS managed rulesets](/ddos-protection/managed-rulesets/) in your zone or account using Terraform. It covers the following configurations:
1415

1516
- [Example: Configure HTTP DDoS Attack Protection](#example-configure-http-ddos-attack-protection)
1617
- [Example: Configure Network-layer DDoS Attack Protection](#example-configure-network-layer-ddos-attack-protection)
1718
- [Use case: Mitigate large HTTP DDoS attacks and monitor flagged traffic](#use-case-mitigate-large-http-ddos-attacks-and-monitor-flagged-traffic)
1819

1920
DDoS managed rulesets are always enabled. Depending on your Cloudflare services, you may be able to adjust their behavior.
2021

21-
For more information on DDoS managed rulesets, refer to [Managed rulesets](/ddos-protection/managed-rulesets/) in the Cloudflare DDoS Protection documentation. For more information on deploying and configuring rulesets using the Rulesets API, refer to [Work with managed rulesets](/ruleset-engine/managed-rulesets/) in the Ruleset Engine documentation.
22+
For more information on deploying and configuring rulesets using the Rulesets API, refer to [Work with managed rulesets](/ruleset-engine/managed-rulesets/) in the Ruleset Engine documentation.
2223

2324
## Before you start
2425

@@ -34,7 +35,7 @@ For more information on DDoS managed rulesets, refer to [Managed rulesets](/ddos
3435

3536
## Example: Configure HTTP DDoS Attack Protection
3637

37-
This example configures the [HTTP DDoS Attack Protection](/ddos-protection/managed-rulesets/http/) managed ruleset for a zone using Terraform, changing the sensitivity level of rule with ID fdfdac75430c4c47a959592f0aa5e68a to `low`.
38+
This example configures the [HTTP DDoS Attack Protection](/ddos-protection/managed-rulesets/http/) managed ruleset for a zone using Terraform, changing the sensitivity level of rule with ID <RuleID id="fdfdac75430c4c47a959592f0aa5e68a" /> to `low`.
3839

3940
<Render file="v4-code-snippets" />
4041

@@ -70,7 +71,7 @@ For more information about HTTP DDoS Attack Protection, refer to [HTTP DDoS Atta
7071

7172
## Example: Configure Network-layer DDoS Attack Protection
7273

73-
This example configures the [Network-layer DDoS Attack Protection](/ddos-protection/managed-rulesets/network/) managed ruleset for an account using Terraform, changing the sensitivity level of rule with ID 599dab0942ff4898ac1b7797e954e98b to `low` using an override.
74+
This example configures the [Network-layer DDoS Attack Protection](/ddos-protection/managed-rulesets/network/) managed ruleset for an account using Terraform, changing the sensitivity level of rule with ID <RuleID id="599dab0942ff4898ac1b7797e954e98b" /> to `low` using an override.
7475

7576
:::caution[Important]
7677

src/content/docs/terraform/additional-configurations/rate-limiting-rules.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
2-
title: Rate limiting rules
2+
title: Rate limiting rules configuration using Terraform
33
pcx_content_type: how-to
44
sidebar:
55
order: 4
6+
label: Rate limiting rules
67
head:
78
- tag: title
8-
content: Configure rate limiting rules with Terraform
9+
content: Rate limiting rules configuration using Terraform
910
---
1011

1112
import { Details, Render } from "~/components";
1213

13-
This page provides an example of creating a rate limiting rule in a zone using Terraform.
14-
15-
For more information on rate limiting rules, refer to [Rate limiting rules](/waf/rate-limiting-rules/) in the Cloudflare WAF documentation.
14+
This page provides examples of creating [rate limiting rules](/waf/rate-limiting-rules/) in a zone or account using Terraform.
1615

1716
:::note
1817

@@ -31,7 +30,7 @@ For more information on configuring the previous version of rate limiting rules
3130

3231
---
3332

34-
## Create a rate limiting rule
33+
## Create a rate limiting rule at the zone level
3534

3635
This example creates a rate limiting rule in zone with ID `<ZONE_ID>` blocking traffic that exceeds the configured rate:
3736

@@ -62,14 +61,15 @@ resource "cloudflare_ruleset" "zone_rl" {
6261

6362
<Render file="add-new-rule" params={{ one: "rate limiting rule" }} /> <br />
6463

65-
<Details header="Account-level example configuration">
64+
## Create a rate limiting rule at the account level
6665

67-
:::note[Before you start]
66+
:::note[Notes]
6867

69-
- Account-level rate limiting configuration requires an Enterprise plan with a paid add-on.
68+
- [Account-level rate limiting configuration](/waf/account/) requires an Enterprise plan with a paid add-on.
7069

7170
- Custom rulesets deployed at the account level will only apply to incoming traffic of zones on an Enterprise plan. The expression of your `execute` rule must end with `and cf.zone.plan eq "ENT"`.
72-
:::
71+
72+
:::
7373

7474
This example defines a [custom ruleset](/ruleset-engine/custom-rulesets/) with a single rate limiting rule in account with ID `<ACCOUNT_ID>` that blocks traffic for the `/api/` path exceeding the configured rate. The second `cloudflare_ruleset` resource defines an `execute` rule that deploys the custom ruleset for traffic addressed at `example.com`.
7575

@@ -120,7 +120,7 @@ resource "cloudflare_ruleset" "account_rl_entrypoint" {
120120
}
121121
```
122122

123-
</Details>
123+
<Render file="add-new-rule" params={{ one: "rate limiting rule" }} /> <br />
124124

125125
## Create an advanced rate limiting rule
126126

src/content/docs/terraform/additional-configurations/transform-rules.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
2-
title: Transform Rules
2+
title: Transform Rules configuration using Terraform
33
pcx_content_type: how-to
44
sidebar:
55
order: 6
6+
label: Transform Rules
67
head:
78
- tag: title
8-
content: Configure Transform Rules with Terraform
9+
content: Transform Rules configuration using Terraform
910
---
1011

1112
import { Render } from "~/components";
1213

13-
This page provides examples of creating Transform Rules in a zone using Terraform. The examples cover the following scenarios:
14+
This page provides examples of creating [Transform Rules](/rules/transform/) in a zone using Terraform. The examples cover the following scenarios:
1415

1516
- [Create a Rewrite URL Rule](#create-a-rewrite-url-rule)
1617
- [Create an HTTP Request Header Modification Rule](#create-an-http-request-header-modification-rule)
17-
18-
For more information on Transform Rules, refer to [Transform Rules](/rules/transform/).
18+
- [Create an HTTP Response Header Modification Rule](#create-an-http-response-header-modification-rule)
1919

2020
## Before you start
2121

0 commit comments

Comments
 (0)