Skip to main content

network_policies

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

Overview

Namenetwork_policies
TypeResource
Idsnowflake.network_policy.network_policies

Fields

The following fields are returned by SELECT queries:

A Snowflake network policy

NameDatatypeDescription
namestringName of the network policy (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
allowed_ip_listarrayList of allowed IPs in a network policy
allowed_network_rule_listarrayList of names of allowed network rules in a network policy
blocked_ip_listarrayList of blocked IPs in a network policy
blocked_network_rule_listarrayList of names of blocked network rules in a network policy
commentstringuser comment associated to an object in the dictionary
created_onstring (date-time)Date and time when the network policy was created.
ownerstringRole that owns the network policy (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
owner_role_typestringThe type of role that owns the network policy (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_network_policiesselectendpointList network policies
fetch_network_policyselectname, endpointFetch a network policy
create_network_policyinsertendpointcreateModeCreate a network policy
delete_network_policydeletename, endpointifExistsDelete a network policy

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
endpointstringOrganization and Account Name (default: orgid-acctid)
namestringIdentifier (i.e. name) for the resource.
createModestringQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
ifExistsbooleanQuery parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.

SELECT examples

List network policies

SELECT
name,
allowed_ip_list,
allowed_network_rule_list,
blocked_ip_list,
blocked_network_rule_list,
comment,
created_on,
owner,
owner_role_type
FROM snowflake.network_policy.network_policies
WHERE endpoint = '{{ endpoint }}' -- required;

INSERT examples

Create a network policy

INSERT INTO snowflake.network_policy.network_policies (
data__name,
data__allowed_network_rule_list,
data__blocked_network_rule_list,
data__allowed_ip_list,
data__blocked_ip_list,
data__comment,
endpoint,
createMode
)
SELECT
'{{ name }}' --required,
'{{ allowed_network_rule_list }}',
'{{ blocked_network_rule_list }}',
'{{ allowed_ip_list }}',
'{{ blocked_ip_list }}',
'{{ comment }}',
'{{ endpoint }}',
'{{ createMode }}'
;

DELETE examples

Delete a network policy

DELETE FROM snowflake.network_policy.network_policies
WHERE name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';