Skip to content

Commit b82b6e9

Browse files
pedrosousasdnts
authored andcommitted
[Rules] Add ref field to Terraform and API examples (cloudflare#22963)
1 parent 7cab824 commit b82b6e9

File tree

22 files changed

+142
-13
lines changed

22 files changed

+142
-13
lines changed

src/content/docs/cache/how-to/cache-rules/terraform-example.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ head:
88
content: Cache Rules — Terraform example
99
---
1010

11-
import { Details } from "~/components";
11+
import { Details, Render } from "~/components";
1212

1313
The following example defines a single cache rule for a zone using Terraform. The rule configures several cache settings and sets a custom cache key for incoming requests addressed at `example.net`.
1414

@@ -82,6 +82,12 @@ resource "cloudflare_ruleset" "cache_rules_example" {
8282
}
8383
```
8484

85+
<Render
86+
file="terraform-use-ref-field"
87+
product="rules"
88+
params={{ addDocsLocation: true }}
89+
/>
90+
8591
</Details>
8692

8793
For additional guidance on using Terraform with Cloudflare, refer to [Terraform](/terraform/).

src/content/docs/rules/compression-rules/examples/disable-all-brotli.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Create a compression rule to turn off Brotli compression for all
99
incoming requests of a given zone.
1010
---
1111

12-
import { Example, TabItem, Tabs, APIRequest } from "~/components";
12+
import { Example, TabItem, Tabs, APIRequest, Render } from "~/components";
1313

1414
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
1515

@@ -40,6 +40,7 @@ The following example sets the rules of an existing [entry point ruleset](/rules
4040
json={{
4141
rules: [
4242
{
43+
ref: "always_use_gzip",
4344
expression: "true",
4445
action: "compress_response",
4546
action_parameters: {
@@ -50,4 +51,6 @@ The following example sets the rules of an existing [entry point ruleset](/rules
5051
}}
5152
/>
5253

54+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
55+
5356
</TabItem> </Tabs>

src/content/docs/rules/compression-rules/examples/disable-compression-avif.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: Create a compression rule to turn off compression for AVIF images,
1111
request.
1212
---
1313

14-
import { Example, TabItem, Tabs, APIRequest } from "~/components";
14+
import { Example, TabItem, Tabs, APIRequest, Render } from "~/components";
1515

1616
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
1717

@@ -42,6 +42,7 @@ The following example sets the rules of an existing [entry point ruleset](/rules
4242
json={{
4343
rules: [
4444
{
45+
ref: "disable_compression_for_avif",
4546
expression:
4647
'http.response.content_type.media_type eq "image/avif" or http.request.uri.path.extension eq "avif"',
4748
action: "compress_response",
@@ -53,4 +54,6 @@ The following example sets the rules of an existing [entry point ruleset](/rules
5354
}}
5455
/>
5556

57+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
58+
5659
</TabItem> </Tabs>

src/content/docs/rules/compression-rules/examples/enable-zstandard.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Enable Zstandard compression for default content types
77
description: Create a compression rule to turn on Zstandard compression for response content types where Cloudflare applies compression by default.
88
---
99

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

1212
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
1313

@@ -38,6 +38,7 @@ The following example sets the rules of an existing [entry point ruleset](/rules
3838
json={{
3939
rules: [
4040
{
41+
ref: "use_zstd_compression",
4142
expression:
4243
'(http.response.content_type.media_type in {"text/html" "text/richtext" "text/plain" "text/css" "text/x-script" "text/x-component" "text/x-java-source" "text/x-markdown" "application/javascript" "application/x-javascript" "text/javascript" "text/js" "image/x-icon" "image/vnd.microsoft.icon" "application/x-perl" "application/x-httpd-cgi" "text/xml" "application/xml" "application/rss+xml" "application/vnd.api+json" "application/x-protobuf" "application/json" "multipart/bag" "multipart/mixed" "application/xhtml+xml" "font/ttf" "font/otf" "font/x-woff" "image/svg+xml" "application/vnd.ms-fontobject" "application/ttf" "application/x-ttf" "application/otf" "application/x-otf" "application/truetype" "application/opentype" "application/x-opentype" "application/font-woff" "application/eot" "application/font" "application/font-sfnt" "application/wasm" "application/javascript-binast" "application/manifest+json" "application/ld+json" "application/graphql+json" "application/geo+json"})',
4344
action: "compress_response",
@@ -49,4 +50,6 @@ The following example sets the rules of an existing [entry point ruleset](/rules
4950
}}
5051
/>
5152

53+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
54+
5255
</TabItem> </Tabs>

src/content/docs/rules/compression-rules/examples/gzip-for-csv.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Create a compression rule to set Gzip compression as the preferred
99
compression method for CSV files.
1010
---
1111

12-
import { Example, TabItem, Tabs, APIRequest } from "~/components";
12+
import { Example, TabItem, Tabs, APIRequest, Render } from "~/components";
1313

1414
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
1515

@@ -40,6 +40,7 @@ The following example sets the rules of an existing [entry point ruleset](/rules
4040
json={{
4141
rules: [
4242
{
43+
ref: "use_gzip_for_csv",
4344
expression: 'http.request.uri.path.extension eq "csv"',
4445
action: "compress_response",
4546
action_parameters: {
@@ -50,4 +51,6 @@ The following example sets the rules of an existing [entry point ruleset](/rules
5051
}}
5152
/>
5253

54+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
55+
5356
</TabItem> </Tabs>

src/content/docs/rules/compression-rules/examples/only-brotli-url-path.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Create a compression rule to set Brotli as the only supported
99
compression algorithm for a specific URI path.
1010
---
1111

12-
import { Example, TabItem, Tabs, APIRequest } from "~/components";
12+
import { Example, TabItem, Tabs, APIRequest, Render } from "~/components";
1313

1414
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
1515

@@ -42,6 +42,7 @@ The following example sets the rules of an existing [entry point ruleset](/rules
4242
json={{
4343
rules: [
4444
{
45+
ref: "use_only_brotli_for_assets_tar",
4546
expression: 'http.request.uri.path eq "/download/assets.tar"',
4647
action: "compress_response",
4748
action_parameters: {
@@ -52,4 +53,6 @@ The following example sets the rules of an existing [entry point ruleset](/rules
5253
}}
5354
/>
5455

56+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
57+
5558
</TabItem> </Tabs>

src/content/docs/rules/configuration-rules/create-api.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The following example sets the rules of an existing phase ruleset (`{ruleset_id}
4343
json={{
4444
rules: [
4545
{
46+
ref: "enable_email_obfuscation_bic",
4647
expression: 'starts_with(http.request.uri.path, "/contact-us/")',
4748
description:
4849
"Obfuscates email addresses and enables BIC in contacts page",
@@ -56,6 +57,8 @@ The following example sets the rules of an existing phase ruleset (`{ruleset_id}
5657
}}
5758
/>
5859

60+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
61+
5962
</Details>
6063

6164
<Details header="Example: Add a rule that turns on Under Attack mode for the admin area">
@@ -68,6 +71,7 @@ The following example sets the rules of an existing phase ruleset (`{ruleset_id}
6871
json={{
6972
rules: [
7073
{
74+
ref: "enable_under_attack_in_admin",
7175
expression: 'http.host eq "admin.example.com"',
7276
description: "Turn on Under Attack mode for admin area",
7377
action: "set_config",
@@ -79,6 +83,8 @@ The following example sets the rules of an existing phase ruleset (`{ruleset_id}
7983
}}
8084
/>
8185

86+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
87+
8288
</Details>
8389

8490
---

src/content/docs/rules/configuration-rules/examples/define-single-configuration-terraform.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ resource "cloudflare_ruleset" "http_config_rules_example" {
3737
}
3838
```
3939

40+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
41+
4042
<Render file="terraform-additional-resources" />

src/content/docs/rules/custom-errors/create-rules.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 3
66
---
77

8-
import { APIRequest } from "~/components";
8+
import { APIRequest, Render } from "~/components";
99

1010
## In the dashboard
1111

@@ -111,6 +111,7 @@ This example configures a custom error rule returning a [previously created cust
111111
json={{
112112
rules: [
113113
{
114+
ref: "serve_500_template",
114115
action: "serve_error",
115116
action_parameters: {
116117
asset_name: "500_error_template",
@@ -123,6 +124,8 @@ This example configures a custom error rule returning a [previously created cust
123124
}}
124125
/>
125126

127+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
128+
126129
This `PUT` request, corresponding to the [Update a zone entry point ruleset](/api/resources/rulesets/subresources/phases/methods/update/) operation, replaces any existing rules in the `http_custom_errors` phase entry point ruleset.
127130

128131
## Required API token permissions

src/content/docs/rules/custom-errors/example-rules.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 4
66
---
77

8-
import { Tabs, TabItem, APIRequest } from "~/components";
8+
import { Tabs, TabItem, APIRequest, Render } from "~/components";
99

1010
The provided examples use the following fields in their rule expressions:
1111

@@ -48,6 +48,7 @@ This example configures a custom JSON error response for all 5XX errors (`500`-`
4848
json={{
4949
rules: [
5050
{
51+
ref: "json_response_for_5xx_errors",
5152
action: "serve_error",
5253
action_parameters: {
5354
content: '{"message": "A server error occurred."}',
@@ -61,6 +62,8 @@ This example configures a custom JSON error response for all 5XX errors (`500`-`
6162
}}
6263
/>
6364

65+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
66+
6467
This `PUT` request, corresponding to the [Update a zone entry point ruleset](/api/resources/rulesets/subresources/phases/methods/update/) operation, replaces any existing rules in the `http_custom_errors` phase entry point ruleset.
6568

6669
</TabItem> </Tabs>
@@ -103,6 +106,7 @@ This example configures a custom HTML error response for responses with a `500`
103106
json={{
104107
rules: [
105108
{
109+
ref: "html_response_500_to_503",
106110
action: "serve_error",
107111
action_parameters: {
108112
content:
@@ -117,6 +121,8 @@ This example configures a custom HTML error response for responses with a `500`
117121
}}
118122
/>
119123

124+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
125+
120126
This `PUT` request, corresponding to the [Update a zone entry point ruleset](/api/resources/rulesets/subresources/phases/methods/update/) operation, replaces any existing rules in the `http_custom_errors` phase entry point ruleset.
121127

122128
</TabItem> </Tabs>
@@ -154,6 +160,7 @@ This example configures a custom HTML error response for [Cloudflare error 1020]
154160
json={{
155161
rules: [
156162
{
163+
ref: "html_response_cf_1020",
157164
action: "serve_error",
158165
action_parameters: {
159166
content:
@@ -167,6 +174,8 @@ This example configures a custom HTML error response for [Cloudflare error 1020]
167174
}}
168175
/>
169176

177+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
178+
170179
This `PUT` request, corresponding to the [Update a zone entry point ruleset](/api/resources/rulesets/subresources/phases/methods/update/) operation, replaces any existing rules in the `http_custom_errors` phase entry point ruleset.
171180

172181
</TabItem> </Tabs>
@@ -204,6 +213,7 @@ This example configures a custom error rule returning a previously created custo
204213
json={{
205214
rules: [
206215
{
216+
ref: "serve_error_500_asset",
207217
action: "serve_error",
208218
action_parameters: {
209219
asset_name: "500_error_template",
@@ -216,6 +226,8 @@ This example configures a custom error rule returning a previously created custo
216226
}}
217227
/>
218228

229+
<Render file="terraform-use-ref-field" params={{ addDocsLocation: true }} />
230+
219231
This `PUT` request, corresponding to the [Update a zone entry point ruleset](/api/resources/rulesets/subresources/phases/methods/update/) operation, replaces any existing rules in the `http_custom_errors` phase entry point ruleset.
220232

221233
</TabItem> </Tabs>

0 commit comments

Comments
 (0)