CREATE NETWORK RULE
statementsupportedIntegrations, network & secretsCreates 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
| Name | Required | Description |
|---|---|---|
name | required | 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 (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 } | required | Specifies 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', ... ] ) | required | Specifies 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 } | optional | Specifies what is restricted by the network rule. Default: INGRESS
|
COMMENT = 'string_literal' | optional | Specifies a comment for the network rule. Default: No value |
Usage notes
- When specifying IP addresses for a network rule, Snowflake supports ranges of IP addresses using Classless Inter-Domain Routing (CIDR) notation. For example, 192.168.1.0/24 represents all IPv4 addresses in the range of 192.168.1.0 to 192.168.1.255.
- CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.
- Regarding metadata: Attention Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
- All limitations of the ALTER NETWORK RULE command apply.
- The TYPE and MODE properties can’t be changed for an existing network rule. If the TYPE or MODE specified in the statement differs from the existing network rule, the statement fails.
- Setting or unsetting a tag is not supported.
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.