Skip to content

Commit 2624fa6

Browse files
committed
lists
1 parent 76a7bb2 commit 2624fa6

File tree

1 file changed

+76
-1
lines changed
  • src/content/partials/cloudflare-one/gateway

1 file changed

+76
-1
lines changed

src/content/partials/cloudflare-one/gateway/lists.mdx

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,42 @@ When you format a CSV file for upload:
2525

2626
To upload the list to Zero Trust:
2727

28+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
29+
2830
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **My Team** > **Lists**.
2931
2. Select **Upload CSV**.
3032
3. Next, specify a **List name**, enter an optional description, and choose a **List type**.
3133
4. Drag and drop a file into the **CSV file** window, or select a file.
3234
5. Select **Create**.
3335

36+
</TabItem>
37+
<TabItem label="Terraform (v5)">
38+
39+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
40+
- `Zero Trust Write`
41+
42+
2. Decode the contents of the CSV file and store it as a local value:
43+
44+
```tf
45+
locals {
46+
ip_list = csvdecode(file("${path.module}/list-test.csv"))
47+
}
48+
```
49+
3. Create a list using the [`cloudflare_zero_trust_list`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_list) resource:
50+
51+
```tf
52+
resource "cloudflare_zero_trust_list" "ips_from_csv" {
53+
account_id = var.cloudflare_account_id
54+
name = "IPs imported from CSV"
55+
description = "Managed by Terraform"
56+
type = "IP"
57+
items = local.ip_list
58+
}
59+
```
60+
61+
</TabItem>
62+
</Tabs>
63+
3464
You can now use this list in the policy builder by choosing the _in list_ operator.
3565

3666
## Create a list manually
@@ -59,6 +89,51 @@ curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/lists \
5989
}'
6090
```
6191

62-
</TabItem> </Tabs>
92+
</TabItem>
93+
<TabItem label="Terraform (v5)">
94+
95+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):
96+
- `Zero Trust Write`
97+
98+
2. Create a list using the [`cloudflare_zero_trust_list`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_list) resource.
99+
100+
Example list of IPs:
101+
```tf
102+
resource "cloudflare_zero_trust_list" "wiki_IPs" {
103+
account_id = var.cloudflare_account_id
104+
name = "Company Wiki IP addresses"
105+
description = "Managed by Terraform"
106+
type = "IP"
107+
items = [
108+
{
109+
description = "Example IP address range"
110+
value = "192.0.2.0/24",
111+
},
112+
{
113+
value = "198.51.100.0/24"
114+
}
115+
]
116+
}
117+
```
118+
119+
Example list of domains:
120+
```tf
121+
resource "cloudflare_zero_trust_list" "wiki_domains" {
122+
account_id = var.cloudflare_account_id
123+
name = "Company Wiki Domains"
124+
description = "Managed by Terraform"
125+
type = "DOMAIN"
126+
items = [
127+
{
128+
value = "wiki.example.com"
129+
},
130+
{
131+
value = "wiki2.example.com"
132+
}]
133+
}
134+
```
135+
136+
</TabItem>
137+
</Tabs>
63138

64139
You can now use this list in the policy builder by choosing the _in list_ operator.

0 commit comments

Comments
 (0)