CREATE NETWORK RULE

statementsupportedIntegrations, network & secrets

docs.snowflake.com ↗

Object: NETWORK RULE

Creates a network rule or replaces an existing network rule. This command supports the following variants: - CREATE OR ALTER NETWORK RULE: Creates a network rule if it doesn’t exist or alters an existing network rule. - DEFINE NETWORK RULE: Declarative definition of a network rule’s target state inside a DCM project.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] NETWORK RULE <name>
   TYPE = { IPV4 | IPV6 | AWSVPCEID | AZURELINKID | GCPPSCID | HOST_PORT | PRIVATE_HOST_PORT | COMPUTE_POOL }
   VALUE_LIST = ( '<value>' [, '<value>', ... ] )
   [ MODE = { INGRESS | INTERNAL_STAGE | SNOWFLAKE_MANAGED_STORAGE_VOLUME | EGRESS } ]
   [ COMMENT = '<string_literal>' ]

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

CREATE OR ALTER NETWORK RULE <name>
   TYPE = { IPV4 | IPV6 | AWSVPCEID | AZURELINKID | GCPPSCID | HOST_PORT | PRIVATE_HOST_PORT | COMPUTE_POOL }
   VALUE_LIST = ( '<value>' [, '<value>', ... ] )
   MODE = { INGRESS | INTERNAL_STAGE | SNOWFLAKE_MANAGED_STORAGE_VOLUME | EGRESS }
   [ COMMENT = '<string_literal>' ]

Parameters

NameRequiredDescription
namerequiredIdentifier 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 (for example, "My object"). Identifiers enclosed in double quotes are case-sensitive. For more details, see Identifier requirements.
TYPE = { IPV4 | IPV6 | AWSVPCEID | AZURELINKID | GCPPSCID | HOST_PORT | PRIVATE_HOST_PORT | COMPUTE_POOL }requiredSpecifies the type of network identifiers being allowed or blocked. A network rule can have only one type. IPV4 indicates that the network rule will allow or block network traffic based on the IPv4 address of the request origin. IPV6 (AWS only) indicates that the network rule will allow or block network traffic based on the IPv6 address of the request origin. IPv6 network rules only support the INGRESS mode. IPv6 addresses can be specified in full, compressed, or IPv4-embedded format, with optional CIDR notation. To enable IPv6 ingress for your account, see IPv6 addresses. AWSVPCEID indicates that the network rule will allow or block network traffic over AWS PrivateLink. AZURELINKID indicates that the network rule will allow or block network traffic over Azure Private Link. GCPPSCID indicates that the network rule will allow or block network traffic over Google Cloud Private Service Connect. HOST_PORT indicates that the network rule will allow outgoing network traffic based on the domain of the request destination. When TYPE = HOST_PORT, the MODE parameter should be set to EGRESS. PRIVATE_HOST_PORT indicates that the network rule allows outgoing network traffic to use private connectivity to an external network location. When TYPE = PRIVATE_HOST_PORT, the MODE parameter must be set to EGRESS. COMPUTE_POOL indicates that the network rule will allow or block network traffic originating from Snowpark Container Services compute pools. The VALUE_LIST specifies the names of compute pools, or 'ALL' to match all SPCS compute pools in the account. For more information, see Allow account access. When TYPE = COMPUTE_POOL, the MODE parameter should be set to INGRESS.
VALUE_LIST = ( 'value' [, 'value', ... ] )requiredSpecifies the network identifiers that will be allowed or blocked. Valid values in the list are determined by the type of network rule: When TYPE = IPV4, each value must be a valid IPv4 address or range of addresses. When TYPE = AWSVPCEID, each value must be a valid VPCE ID. VPC IDs are not supported. When TYPE = AZURELINKID, each value must be a valid LinkID of an Azure private endpoint. Execute the SYSTEM$GET_PRIVATELINK_AUTHORIZED_ENDPOINTS function to retrieve the LinkID associated with an account. When TYPE = GCPPSCID, each value must be a valid pscConnectionID of a Google Cloud Private Service Connect (PSC) endpoint. Run the gcloud compute forwarding-rules describe command to get the pscConnectionID for each forwarding rule. When TYPE = HOST_PORT, each value must resolve to a valid domain. Optionally, it can also include a port or range of ports. In most cases, the valid port range is 1-65535. If you do not specify a port, it defaults to 443. If an external network location supports dynamic ports, you need to specify all possible ports. To allow access to all ports, define the port as 0; for example, example.com:0. When the value resolves to a domain, you can use a single asterisk as a wildcard character. The asterisk matches only alphanumeric characters and hyphens (-). Wildcards are supported only for a single level of subdomains, as in the following examples: *.google.com snowflake-*.google.com and snowflake*abc.google.com You can allow requests to all outbound endpoints by specifying 0.0.0.0 as the domain, as in the examples below. When you specify 0.0.0.0 as the domain, you may use only 443 and 80 as port values. Allow access to all endpoints at port 80 Copy code value_list = ('0.0.0.0:80'); Allow access to all endpoints at port 443 Copy code value_list = ('0.0.0.0:443'); Copy code value_list = ('0.0.0.0'); Allow access to all endpoints at both port 80 and 443 Copy code value_list = ('0.0.0.0:80', '0.0.0.0:443'); When TYPE = PRIVATE_HOST_PORT, specify one valid domain. In most cases, the valid port range is 1-65535. If you do not specify a port, it defaults to 443. If an external network location supports dynamic ports, you need to specify all possible ports. To allow access to all ports, define the port as 0; for example, example.com:0. When TYPE = COMPUTE_POOL, each value must be a valid compute pool name, or 'ALL' to match all Snowpark Container Services compute pools in the account.
MODE = { INGRESS | INTERNAL_STAGE | SNOWFLAKE_MANAGED_STORAGE_VOLUME | EGRESS }optionalSpecifies what is restricted by the network rule. Default: INGRESS
  • INGRESS — The behavior of the INGRESS mode depends on the value of the network rule’s TYPE property. If TYPE=IPV4, by default the network rule controls access to the Snowflake service only. If the account administrator enables the ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES parameter, then MODE=INGRESS and TYPE=IPV4 also protects an AWS internal stage. If TYPE=IPV6, the network rule controls access to the Snowflake service only. Internal stage network policies don’t consider IPv6 network rules. If TYPE=AWSVPCEID, TYPE=AZURELINKID, or TYPE=GCPPSCID, then the network rule controls access to the Snowflake service only.
  • INTERNAL_STAGE — Allows or blocks requests to an AWS internal stage without restricting access to the Snowflake service. Using this mode requires the following: The account administrator must enable the ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES parameter. The TYPE property of the network rule must be AWSVPCEID.
  • SNOWFLAKE_MANAGED_STORAGE_VOLUME — Allows or blocks requests to an AWS Snowflake-managed storage volume without restricting access to the Snowflake service. Using this mode requires the following: The account administrator must enable the ENFORCE_NETWORK_RULES_FOR_SNOWFLAKE_MANAGED_STORAGE_VOLUME parameter. The TYPE property of the network rule must be AWSVPCEID.
  • EGRESS — Allows Snowflake to send requests to an external destination.
COMMENT = 'string_literal'optionalSpecifies a comment for the network rule. 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 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. OWNERSHIP | Network Rule | Required to execute a CREATE OR ALTER NETWORK RULE statement for an existing network rule. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent 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 on securable objects, see Overview of Access Control.

See also

Referenced by