Skip to content

Commit ec828f0

Browse files
authored
[Rules] Cloud Connector: Terraform example (#18883)
1 parent 89c8457 commit ec828f0

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Configure Cloud Connector using Terraform
3+
pcx_content_type: how-to
4+
sidebar:
5+
order: 4
6+
label: Configure using Terraform
7+
head:
8+
- tag: title
9+
content: Configure Cloud Connector using Terraform
10+
---
11+
12+
You can create Cloud Connector using the [Terraform Cloudflare provider](https://registry.terraform.io/providers/cloudflare/cloudflare/latest).
13+
14+
To get started with Terraform for Cloudflare configuration, refer to [Terraform: Get started](/terraform/installing/).
15+
16+
## Example configuration
17+
18+
Below is an example Terraform configuration that demonstrates creating Cloud Connectors for various [supported providers](/rules/cloud-connector/providers/) to route traffic between them based on URI paths:
19+
20+
```tf
21+
resource "cloudflare_cloud_connector_rules" "cloud_connector_rules" {
22+
zone_id = "<ZONE_ID>"
23+
24+
rules {
25+
description = "Route /data to GCP bucket"
26+
enabled = true
27+
expression = "(http.request.uri.path wildcard \"*/data/*\")"
28+
provider = "gcp_storage"
29+
parameters {
30+
host = "mystorage.storage.googleapis.com"
31+
}
32+
}
33+
34+
rules {
35+
description = "Route /resources to AWS bucket"
36+
enabled = true
37+
expression = "(http.request.uri.path wildcard \"*/resources/*\")"
38+
provider = "aws_s3"
39+
parameters {
40+
host = "mystorage.s3.ams.amazonaws.com"
41+
}
42+
}
43+
44+
rules {
45+
description = "Route /files to Azure bucket"
46+
enabled = true
47+
expression = "(http.request.uri.path wildcard \"*/files/*\")"
48+
provider = "azure_storage"
49+
parameters {
50+
host = "mystorage.blob.core.windows.net"
51+
}
52+
}
53+
54+
rules {
55+
description = "Route /images to R2 bucket"
56+
enabled = true
57+
expression = "(http.request.uri.path wildcard \"*/images/*\")"
58+
provider = "cloudflare_r2"
59+
parameters {
60+
host = "mybucketcustomdomain.example.com"
61+
}
62+
}
63+
}
64+
```
65+
66+
## More resources
67+
68+
Refer to the [Terraform Cloudflare provider documentation](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs) for more information on the `cloudflare_cloud_connector_rules` resource.

0 commit comments

Comments
 (0)