Skip to content

Commit 0a78d47

Browse files
committed
Added API and Terraform code to create the allow list policy
1 parent e3975b6 commit 0a78d47

File tree

1 file changed

+39
-0
lines changed
  • src/content/docs/learning-paths/secure-internet-traffic/build-dns-policies

1 file changed

+39
-0
lines changed

src/content/docs/learning-paths/secure-internet-traffic/build-dns-policies/create-list.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,47 @@ Gateway supports creating [lists](/cloudflare-one/policies/gateway/lists/) of UR
1212

1313
## Example list policy
1414

15+
<Tabs syncKey="dashPlusAPI">
16+
<TabItem label="Dashboard">
1517
The following DNS policy will allow access to all approved corporate domains included in a list called **Corporate Domains**.
1618

1719
| Selector | Operator | Value | Action |
1820
| -------- | -------- | ------------------- | ------ |
1921
| Domain | in list | *Corporate Domains* | Allow |
22+
</TabItem>
23+
<TabItem label="API">
24+
```sh
25+
curl --request POST \
26+
--url https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
27+
--header 'Content-Type: application/json' \
28+
--header "Authorization: Bearer <API TOKEN>" \
29+
--data '{
30+
"name": "All-DNS-CorporateDomain-AllowList",
31+
"description": "Allow access to the corporate domains defined under the Corporate Domains list",
32+
"precedence": 1,
33+
"enabled": false,
34+
"action": "allow",
35+
"filters": [
36+
"dns"
37+
],
38+
"traffic": "any(dns.domains[*] in $<Corporate Domains List UUID>)"
39+
}'
40+
41+
```
42+
</TabItem>
43+
<TabItem label="Terraform">
44+
To create a new DNS policy using **Terraform** to allow access to all approved corporate domains included in a list called **Corporate Domains**.
45+
```tf
46+
resource "cloudflare_zero_trust_gateway_policy" "allow_corporate_domain_access" {
47+
account_id = var.account_id
48+
name = "All-DNS-CorporateDomain-AllowList"
49+
description = "Allow access to the corporate domains defined under the Corporate Domains list"
50+
precedence = 1
51+
enabled = false
52+
action = "allow"
53+
filters = ["dns"]
54+
traffic = "any(dns.domains[*] in $<Corporate Domains List UUID>)"
55+
}
56+
```
57+
</TabItem>
58+
</Tabs>

0 commit comments

Comments
 (0)