CREATE NETWORK POLICY

statementsupportedIntegrations, network & secrets

docs.snowflake.com ↗

Object: NETWORK POLICY

Creates a network policy or replaces an existing network policy. This command supports the following variants: - CREATE OR ALTER NETWORK POLICY: Creates a network policy if it doesn’t exist or alters an existing network policy. - DEFINE NETWORK POLICY: Declarative definition of a network policy’s target state inside a DCM project. Note Only security administrators (that is, users with the SECURITYADMIN role) or higher or a role with the global CREATE NETWORK POLICY privilege can create network policies.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] NETWORK POLICY [ IF NOT EXISTS ] <name>
  [ ALLOWED_NETWORK_RULE_LIST = ( '<network_rule>' [ , '<network_rule>' , ... ] ) ]
  [ BLOCKED_NETWORK_RULE_LIST = ( '<network_rule>' [ , '<network_rule>' , ... ] ) ]
  [ ALLOWED_IP_LIST = ( [ '<ip_address>' ] [ , '<ip_address>' , ... ] ) ]
  [ BLOCKED_IP_LIST = ( [ '<ip_address>' ] [ , '<ip_address>' , ... ] ) ]
  [ COMMENT = '<string_literal>' ]

For more information, see CREATE OR ALTER <object>.

CREATE OR ALTER NETWORK POLICY <name>
  [ ALLOWED_NETWORK_RULE_LIST = ( '<network_rule>' [ , '<network_rule>' , ... ] ) ]
  [ BLOCKED_NETWORK_RULE_LIST = ( '<network_rule>' [ , '<network_rule>' , ... ] ) ]
  [ ALLOWED_IP_LIST = ( [ '<ip_address>' ] [ , '<ip_address>' , ... ] ) ]
  [ BLOCKED_IP_LIST = ( [ '<ip_address>' ] [ , '<ip_address>' , ... ] ) ]
  [ COMMENT = '<string_literal>' ]

Parameters

NameRequiredDescription
namerequiredIdentifier for the network policy; must be unique for your account. The identifier value must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more details, see Identifier requirements.
ALLOWED_NETWORK_RULE_LIST = ( 'network_rule' [ , 'network_rule' , ... ] )optionalSpecifies a list of network rules that contain the network identifiers that are allowed access to Snowflake. There is no limit on the number of network rules in the list.
BLOCKED_NETWORK_RULE_LIST = ( 'network_rule' [ , 'network_rule' , ... ] )optionalSpecifies a list of network rules that contain the network identifiers that are denied access to Snowflake. There is no limit on the number of network rules in the list.
ALLOWED_IP_LIST = ( [ ip_address ] [ , ip_address , ... ] )optionalSpecifies a list of IPv4 addresses that are allowed access to your Snowflake account. This is referred to as the allowed list. Snowflake recommends using network rules in conjunction with network policies rather than using this property. Use the ALLOWED_NETWORK_RULE_LIST property to specify network rules that contain IPv4 or IPv6 addresses. If you are not yet using network rules, specify at least one IPv4 address or CIDR block range to allow access to your Snowflake account. Additionally, if you are not using network rules and this property is specified with an empty list, no IPv4 addresses are allowed to access your Snowflake account. Note The ALLOWED_IP_LIST parameter supports IPv4 addresses only. To allow or block IPv6 addresses, use network rules with TYPE = IPV6 and add them to the ALLOWED_NETWORK_RULE_LIST or BLOCKED_NETWORK_RULE_LIST. IPv4 and IPv6 network rules are evaluated independently, so if your network has dual-stack (IPv4 and IPv6) traffic, create separate network rules for each address family and add both to the network policy. To enable IPv6 ingress for your account, see IPv6 addresses.
BLOCKED_IP_LIST = ( [ ip_address ] [ , ip_address , ... ] )optionalSpecifies a list of IPv4 addresses that are denied access to your Snowflake account. This is referred to as the blocked list. To unset this parameter, specify a different CIDR block range, a series of IPv4 addresses, or a single IPv4 address. Snowflake recommends using network rules in conjunction with network policies rather than using this parameter. Use the BLOCKED_NETWORK_RULE_LIST property to specify network rules that contain IPv4 or IPv6 addresses. To block public access, use a network rule and add the network rule to the BLOCKED_NETWORK_RULE_LIST property. The result is that only IP addresses that use private connectivity, such as AWS PrivateLink, can access your Snowflake account. Default: No value; no IP addresses in ALLOWED_IP_LIST property are blocked.
COMMENT = 'string_literal'optionalSpecifies a comment for the network policy. Default: No value

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE NETWORK POLICY | Account | Only the SECURITYADMIN role, or a higher role, has this privilege by default. The privilege can be granted to additional roles as needed. OWNERSHIP | Network Policy | Required to execute a CREATE OR ALTER NETWORK POLICY statement for an existing network policy. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Example

Create a network policy named allow_vpceid_block_public_policy based on two network rules, one that allows a VPCE ID and one that blocks public network traffic, as described in Interaction between allowed lists and blocked lists. Create a new network policy or update the allowed and blocked network rule lists for an existing policy:

See also

Referenced by