Accounts and Security · Topic 12 of 17

Network Rules and External Network Access

Use network rules and external access integrations so UDFs and procedures can call outside services safely, with allowed hosts and secrets for credentials.

  • 5 min
In a nutshell
  • A network rule groups identifiers; a policy or an integration gives it meaning.
  • Ingress rules (IPv4, private endpoint IDs) feed network policies; egress rules (HOST_PORT) feed external access integrations.
  • External access needs three objects: egress network rule, secret and external access integration.

What it is

A network rule is a schema level object that groups network identifiers, such as IP ranges, private endpoint IDs or host names with ports. A rule does not allow or block anything by itself. What it does depends on where it is used.

Rules serve two directions. Inbound rules feed network policies (who may reach Snowflake). Outbound rules feed external access integrations (where handler code may connect).

Network ruleidentifiersused inNetwork policyinbound controlNetwork ruleHOST_PORT, egressused inExternal access integrationoutbound controlgranted toUDF or procedure

How it works

Network rule properties

Every rule has a TYPE (what the values are) and a MODE (what the rule is for).

TYPEValuesTypical use
IPV4IP addresses and CIDR rangesAllow office or data center ranges
AWSVPCEIDAWS VPC endpoint IDsAllow traffic that arrives over AWS PrivateLink
AZURELINKIDAzure Private Link resource identifiersAllow traffic from an Azure private endpoint
GCPPSCIDGoogle Private Service Connect endpoint IDsAllow traffic from a Google private endpoint
HOST_PORTHost names with optional portsOutbound calls to an API
PRIVATE_HOST_PORTHost names with optional portsOutbound calls over private connectivity
MODEMeaning
INGRESSInbound traffic to the Snowflake service, for network policies
INTERNAL_STAGEInbound traffic to internal stages (AWSVPCEID only, AWS)
EGRESSOutbound traffic from Snowflake, for external access
CREATE NETWORK RULE corp_ranges
  MODE = INGRESS
  TYPE = IPV4
  VALUE_LIST = ('203.0.113.0/24', '198.51.100.7');

Rules make policies easier to manage than raw IP lists. A rule can be reused in several policies, and its owner can update the values without editing each policy.

Exam tip

Use TYPE = IPV4 for the public path and a private endpoint type such as AWSVPCEID for the private path, in separate rules. When a request arrives over private connectivity and a matching endpoint rule is in the allowed list, the IP rules are ignored for that request.

Why external network access exists

By default, code that runs inside Snowflake, such as a Python UDF or stored procedure, cannot reach the internet. That is a safe default: the code cannot send data out, and an attacker who injects code cannot either.

When a function must call a REST API, an Architect opens a narrow path rather than turning access fully on. Three objects work together.

ObjectRole
Network rule (MODE = EGRESS, TYPE = HOST_PORT)Lists the hosts the code may call
SecretStores a credential such as a username and password, an API key or an OAuth token
External access integrationBundles allowed rules and allowed secrets, and is granted to code
Network ruleapi.example.com:443listed inIntegrationALLOWED_NETWORK_RULESattached toFunctionEXTERNAL_ACCESS_INTEGRATIONSreadsSecretcredentials

Setting it up

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

CREATE SECRET api_key
  TYPE = GENERIC_STRING
  SECRET_STRING = '...';

CREATE EXTERNAL ACCESS INTEGRATION api_integration
  ALLOWED_NETWORK_RULES = (api_rule)
  ALLOWED_AUTHENTICATION_SECRETS = (api_key)
  ENABLED = TRUE;

CREATE FUNCTION call_api(x STRING)
  RETURNS STRING
  LANGUAGE PYTHON
  RUNTIME_VERSION = '3.12'
  HANDLER = 'run'
  EXTERNAL_ACCESS_INTEGRATIONS = (api_integration)
  SECRETS = ('key' = api_key)
  AS $$ ... $$;

The secret is read inside the handler through the secret API and is never written in the function body. Handler code in UDFs and stored procedures can use the integration. The role that creates the function needs USAGE on the integration.

Public or private egress

Outbound calls can go over the public internet, or over a private network using AWS PrivateLink, Azure Private Link or Google Cloud Private Service Connect. Private outbound connectivity uses an egress rule with TYPE = PRIVATE_HOST_PORT and needs Business Critical or higher. For on-premises sources and other systems that a cloud private endpoint cannot reach, Snowflake offers the Data Connectivity Proxy.

Watch out

An egress rule is a data exfiltration path. List only the exact hosts the code needs, and never use a wildcard approach to save effort.

Choosing the right object

ScenarioAnswer
Limit which networks can log inNetwork policy with ingress rules
Allow a UDF to call one REST APIEgress network rule plus external access integration
Give the UDF an API key without exposing itA secret listed in ALLOWED_AUTHENTICATION_SECRETS
Allow Snowflake OAuth users from private endpoints onlyPrivate endpoint rule in a network policy

Common mistakes

Thinking a network rule is a policy. A rule only groups identifiers. Nothing is enforced until it is attached to a policy or an integration.

Using an ingress rule for outbound access. Outbound access needs MODE = EGRESS with TYPE = HOST_PORT (or PRIVATE_HOST_PORT for private egress).

Hard coding credentials in function code. Use a secret and list it in the integration.

Forgetting to attach the integration. Creating the integration is not enough. The function or procedure must name it in EXTERNAL_ACCESS_INTEGRATIONS.

What to remember for the exam

  • A network rule groups identifiers; a policy or an integration gives it meaning.
  • Ingress rules (IPv4, private endpoint IDs) feed network policies; egress rules (HOST_PORT) feed external access integrations.
  • External access needs three objects: egress network rule, secret and external access integration.
  • The function or procedure must reference the integration with EXTERNAL_ACCESS_INTEGRATIONS.
  • Private connectivity for outbound calls needs Business Critical or higher.

Check yourself

  • A Python UDF must call one partner API with an API key. Which objects are needed?

    An egress network rule listing the host, a secret holding the key, and an external access integration that allows both, referenced by the UDF.

  • What do the MODE values INGRESS and EGRESS distinguish?

    INGRESS rules govern traffic coming into Snowflake and are used in network policies. EGRESS rules govern outbound calls and are used in external access integrations.

  • Why use a secret instead of putting the key in the handler code?

    The secret keeps the credential out of the source and lets you control which integration may use it.

Topic 12 of 17 in Accounts and Security

Test yourself on Accounts and Security

The full Snowflake ARA-C01 question bank has 687 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.