CREATE NETWORK RULE | Snowflake Documentation (original) (raw)

Creates a network rule or replaces an existing network rule.

See also:

ALTER NETWORK RULE , DROP NETWORK RULE , SHOW NETWORK RULES ,DESCRIBE NETWORK RULE

Syntax

CREATE [ OR REPLACE ] NETWORK RULE TYPE = { IPV4 | AWSVPCEID | AZURELINKID | HOST_PORT | PRIVATE_HOST_PORT } VALUE_LIST = ( '' [, '', ... ] ) MODE = { INGRESS | INTERNAL_STAGE | EGRESS } [ COMMENT = '' ]

Required parameters

_name_

Identifier for the network rule.

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 (e.g. "My object"). Identifiers enclosed in double quotes are case-sensitive.

For more details, see Identifier requirements.

TYPE = { IPV4 | AWSVPCEID | AZURELINKID | HOST_PORT | PRIVATE_HOST_PORT }

Specifies the type of network identifiers being allowed or blocked. A network rule can have only one type.

VALUE_LIST = ( '_value_' [, '_value_', ... ] )

Specifies the network identifiers that will be allowed or blocked.

Valid values in the list are determined by the type of network rule:

MODE = { INGRESS | INTERNAL_STAGE | EGRESS }

Specifies what is restricted by the network rule.

INGRESS

The behavior of the INGRESS mode depends on the value of the network rule’s TYPE property.

INTERNAL_STAGE

Allows or blocks requests to an AWS internal stage without restricting access to the Snowflake service. Using this mode requires the following:

EGRESS

Allows Snowflake to send requests to an external destination.

Default: INGRESS

Optional parameters

COMMENT = '_stringliteral_'

Specifies a comment for the network rule.

Default: No value

Access control requirements

A role used to execute this operation must have the followingprivileges at a minimum:

Privilege Object Notes
CREATE NETWORK RULE Schema Only the ACCOUNTADMIN and SECURITYADMIN roles, along with the schema owner, have this privilege by default. It can be granted to additional roles as needed.

The USAGE privilege on the parent database and schema are required to perform operations on any object in a schema.

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 onsecurable objects, see Overview of Access Control.

Usage notes

Examples

Create a network rule that is used to allow or block traffic from an AWS S3 endpoint to the internal stage:

CREATE NETWORK RULE corporate_network TYPE = AWSVPCEID VALUE_LIST = ('vpce-123abc3420c1931') MODE = INTERNAL_STAGE COMMENT = 'corporate privatelink endpoint';

Create a network rule that is used to allow or block traffic from a range of IP addresses to the Snowflake service and internal stage:

CREATE NETWORK RULE cloud_network TYPE = IPV4 VALUE_LIST = ('47.88.25.32/27') COMMENT ='cloud egress ip range';

Create a network rule that is used to allow a domain and domain/port combination when Snowflake is sending requests to external destinations:

CREATE NETWORK RULE external_access_rule TYPE = HOST_PORT MODE = EGRESS VALUE_LIST = ('example.com', 'example.com:443');

Create a network rule to enable outbound private connectivity forexternal network access:

CREATE OR REPLACE NETWORK RULE ext_network_access_db.network_rules.azure_sql_private_rule MODE = EGRESS TYPE = PRIVATE_HOST_PORT VALUE_LIST = ('externalaccessdemo.database.windows.net');