Skip to main content

gateway_rules

Creates, updates, deletes, gets or lists a gateway_rules resource.

Overview

Namegateway_rules
TypeResource
Idcloudflare.zero_trust.gateway_rules

Fields

The following fields are returned by SELECT queries:

Get Zero Trust Gateway rule details response.

NameDatatypeDescription
idstringIdentify the API resource with a UUID. (example: f174e90a-fafe-4643-bbbc-4a0ed4fc8415)
namestringSpecify the rule name. (example: block bad websites)
actionstringSpecify the action to perform when the associated traffic, identity, and device posture expressions either absent or evaluate to true. (on, off, allow, block, scan, noscan, safesearch, ytrestricted, isolate, noisolate, override, l4_override, egress, resolve, quarantine, redirect) (example: allow)
created_atstring (date-time) (example: 2014-01-01T05:20:00.12345Z)
deleted_atstring (date-time)Indicate the date of deletion, if any. (x-stainless-terraform-configurability: computed)
descriptionstringSpecify the rule description. (example: Block bad websites based on their host name.)
device_posturestringSpecify the wirefilter expression used for device posture check. The API automatically formats and sanitizes expressions before storing them. To prevent Terraform state drift, use the formatted expression returned in the API response. (default: , example: any(device_posture.checks.passed[*] in {"1308749e-fcfb-4ebc-b051-fe022b632644"}), x-stainless-terraform-configurability: computed_optional)
enabledbooleanSpecify whether the rule is enabled.
expirationobjectDefines the expiration time stamp and default duration of a DNS policy. Takes precedence over the policy's schedule configuration, if any. This does not apply to HTTP or network policies. Settable only for dns rules. (x-stainless-terraform-configurability: computed_optional)
filtersarraySpecify the protocol or layer to evaluate the traffic, identity, and device posture expressions. Can only contain a single value.
identitystringSpecify the wirefilter expression used for identity matching. The API automatically formats and sanitizes expressions before storing them. To prevent Terraform state drift, use the formatted expression returned in the API response. (default: , example: any(identity.groups.name[*] in {"finance"}), x-stainless-terraform-configurability: computed_optional)
precedenceintegerSet the order of your rules. Lower values indicate higher precedence. At each processing phase, evaluate applicable rules in ascending order of this value. Refer to Order of enforcement to manage precedence via Terraform. (x-stainless-terraform-configurability: computed_optional)
read_onlybooleanIndicate that this rule is shared via the Orgs API and read only. (x-stainless-terraform-configurability: computed)
rule_settingsobjectDefines settings for this rule. Settings apply only to specific rule types and must use compatible selectors. If Terraform detects drift, confirm the setting supports your rule type and check whether the API modifies the value. Use API-returned values in your configuration to prevent drift. (x-stainless-terraform-configurability: computed_optional)
scheduleobjectDefines the schedule for activating DNS policies. Settable only for dns and dns_resolver rules. (x-stainless-terraform-configurability: computed_optional)
sharablebooleanIndicate that this rule is sharable via the Orgs API. (x-stainless-terraform-configurability: computed)
source_accountstringProvide the account tag of the account that created the rule. (x-stainless-terraform-configurability: computed)
trafficstringSpecify the wirefilter expression used for traffic matching. The API automatically formats and sanitizes expressions before storing them. To prevent Terraform state drift, use the formatted expression returned in the API response. (default: , example: http.request.uri matches ".a/partial/uri." and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10, x-stainless-terraform-configurability: computed_optional)
updated_atstring (date-time) (example: 2014-01-01T05:20:00.12345Z)
versionintegerIndicate the version number of the rule(read-only). (x-stainless-terraform-configurability: computed)
warning_statusstringIndicate a warning for a misconfigured rule, if any. (x-stainless-terraform-configurability: computed)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectrule_id, account_idGet a single Zero Trust Gateway rule.
listselectaccount_idList Zero Trust Gateway rules for an account.
createinsertaccount_id, name, actionCreate a new Zero Trust Gateway rule.
updatereplacerule_id, account_id, name, actionUpdate a configured Zero Trust Gateway rule.
deletedeleterule_id, account_idDelete a Zero Trust Gateway rule.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
rule_idstringThe rule ID.

SELECT examples

Get a single Zero Trust Gateway rule.

SELECT
id,
name,
action,
created_at,
deleted_at,
description,
device_posture,
enabled,
expiration,
filters,
identity,
precedence,
read_only,
rule_settings,
schedule,
sharable,
source_account,
traffic,
updated_at,
version,
warning_status
FROM cloudflare.zero_trust.gateway_rules
WHERE rule_id = '{{ rule_id }}' -- required
AND account_id = '{{ account_id }}' -- required
;

INSERT examples

Create a new Zero Trust Gateway rule.

INSERT INTO cloudflare.zero_trust.gateway_rules (
action,
description,
device_posture,
enabled,
expiration,
filters,
identity,
name,
precedence,
rule_settings,
schedule,
traffic,
account_id
)
SELECT
'{{ action }}' /* required */,
'{{ description }}',
'{{ device_posture }}',
{{ enabled }},
'{{ expiration }}',
'{{ filters }}',
'{{ identity }}',
'{{ name }}' /* required */,
{{ precedence }},
'{{ rule_settings }}',
'{{ schedule }}',
'{{ traffic }}',
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;

REPLACE examples

Update a configured Zero Trust Gateway rule.

REPLACE cloudflare.zero_trust.gateway_rules
SET
action = '{{ action }}',
description = '{{ description }}',
device_posture = '{{ device_posture }}',
enabled = {{ enabled }},
expiration = '{{ expiration }}',
filters = '{{ filters }}',
identity = '{{ identity }}',
name = '{{ name }}',
precedence = {{ precedence }},
rule_settings = '{{ rule_settings }}',
schedule = '{{ schedule }}',
traffic = '{{ traffic }}'
WHERE
rule_id = '{{ rule_id }}' --required
AND account_id = '{{ account_id }}' --required
AND name = '{{ name }}' --required
AND action = '{{ action }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Delete a Zero Trust Gateway rule.

DELETE FROM cloudflare.zero_trust.gateway_rules
WHERE rule_id = '{{ rule_id }}' --required
AND account_id = '{{ account_id }}' --required
;