In this post we are going to cover network policies and network rules in Snowflake.
A network policy is a named object that holds a list of IP addresses. When it is applied to an account or to a user, it decides which addresses are allowed to reach that account. A network rule is a separate object that holds a list of values, and a policy can be built out of rules instead of out of addresses.
We will start by looking at what is already on the account, then create a policy, read it back two different ways, and build it up step by step.
One thing to say before anything else. Nothing on this page is ever applied to anything. Every policy here is created, read and dropped, and not one of them is attached to the account or to a user. A network policy decides who can reach the account, and the only account here is the one these queries were run on. Two questions below end with “I do not know” because of that, and saying so is better than finding out the hard way on a live account.
Every address used below comes from a range reserved for documentation, so no real network is named anywhere.
Episode 164 of the Snowflake SQL: Zero to Hero series on TechBrothersIT.
- Let's see what is on this account before we start
- Let's create our first network policy
- Now let's see what the IP list will take
- What happens when the value is not an IPv4 address?
- Now let's try three policies that should not make sense
- Let's change a policy with ALTER
- Now let's make a network rule
- A type and a mode, and the two are paired
- Let's build a policy out of a rule instead of addresses
- Can we drop a rule a policy is using?
- Now the names that exist and the names that do not
- One last thing: let's put the account back
Let's see what is on this account before we start
There is no sample table in this post. The objects we are about to make are account-level objects, so the first thing worth knowing is what is already there.
Let's ask for every network policy on the account.
SHOW NETWORK POLICIES;| created_on | name | comment | entries_in_allowed_ip_list | entries_in_blocked_ip_list | entries_in_allowed_network_rules | entries_in_blocked_network_rules |
|---|
Column headings and nothing underneath. The count says the same thing in one cell.
SELECT COUNT(*) AS POLICIES_ALREADY_HERE
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| POLICIES_ALREADY_HERE |
|---|
| 0 |
Now the same question about network rules.
SHOW NETWORK RULES;| created_on | name | database_name | schema_name | owner | comment | type | mode | entries_in_valuelist | owner_role_type |
|---|
SELECT COUNT(*) AS RULES_ALREADY_HERE
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| RULES_ALREADY_HERE |
|---|
| 0 |
So everything we see from here on is ours. Nothing on this account was restricting who could reach it.
And the parameter that decides whether a policy is in force
A policy only does anything once it is applied, and what it is applied to is a parameter called NETWORK_POLICY. Let's read it on the account.
SHOW PARAMETERS LIKE 'NETWORK_POLICY' IN ACCOUNT;| key | value | default | level | description | type |
|---|---|---|---|---|---|
| NETWORK_POLICY | Network policy assigned for the given target. | STRING |
One row. The value cell is empty, which means no policy is in force. Let's read the same row back with the columns we care about.
SELECT "key", "value", "default", "level", "description"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| key | value | default | level | description |
|---|---|---|---|---|
| NETWORK_POLICY | Network policy assigned for the given target. |
The same parameter can be set on a single user as well. The statement for that names a user, so the name below stands in for the real one.
-- The same question asked about one user instead of the account.
-- The real statement names a user, so the name below stands in for it.
SHOW PARAMETERS LIKE 'NETWORK_POLICY' IN USER YOUR_USER_NAME;| key | value | default | level |
|---|---|---|---|
| NETWORK_POLICY |
Empty there too. Nothing is restricting this account at the account level or at the user level, and that is how it stays all the way through.
Do not apply a policy you have just written to the account you are working from. If the list is wrong, the thing you have locked out is yourself. Create it, read it, and test it against an account you can afford to lose access to.
Let's create our first network policy
The smallest useful policy is a name and one allowed range.
CREATE OR REPLACE NETWORK POLICY NP_T164
ALLOWED_IP_LIST = ('192.0.2.0/24')
COMMENT = 'episode 164 - created, read, dropped, and NEVER APPLIED to anything';| status |
|---|
| Network policy NP_T164 is created. |
Created. Now let's find it in the catalogue.
SHOW NETWORK POLICIES LIKE 'NP\\_T164';| created_on | name | comment | entries_in_allowed_ip_list | entries_in_blocked_ip_list | entries_in_allowed_network_rules | entries_in_blocked_network_rules |
|---|---|---|---|---|---|---|
| 2026-10-06 12:21:59.705000-07:00 | NP_T164 | episode 164 - created, read, dropped, and NEVER APPLIED to anything | 1 | 0 | 0 | 0 |
One row, and four of its columns are counts. entries_in_allowed_ip_list reads 1 and the other three read 0.
SELECT "name", "comment", "entries_in_allowed_ip_list",
"entries_in_blocked_ip_list", "created_on"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | comment | entries_in_allowed_ip_list | entries_in_blocked_ip_list | created_on |
|---|---|---|---|---|
| NP_T164 | episode 164 - created, read, dropped, and NEVER APPLIED to anything | 1 | 0 | 2026-10-06 12:21:59.705000-07:00 |
Now let's ask DESCRIBE the same question
SHOW gave us counts. DESCRIBE gives us contents, and that is a different answer to the same question.
DESCRIBE NETWORK POLICY NP_T164;| name | value |
|---|---|
| ALLOWED_IP_LIST | 192.0.2.0/24 |
One row with two columns, a property name and its value. This is where the address itself lives.
SELECT COUNT(*) AS DESCRIBE_ROWS
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| DESCRIBE_ROWS |
|---|
| 1 |
So keep both in mind. SHOW NETWORK POLICIES tells you how many entries a policy has. DESCRIBE NETWORK POLICY tells you what they are. Neither one is the full picture on its own.
Now let's see what the IP list will take
The first policy used a range written with a CIDR suffix. Let's try a single address with nothing after it.
CREATE OR REPLACE NETWORK POLICY NPONE_T164
ALLOWED_IP_LIST = ('203.0.113.7');| status |
|---|
| Network policy NPONE_T164 is created. |
Accepted. And here is what it stored.
DESCRIBE NETWORK POLICY NPONE_T164;| name | value |
|---|---|
| ALLOWED_IP_LIST | 203.0.113.7 |
Exactly what we typed. Snowflake did not add a /32 on our behalf, and it did not rewrite the value at all.
Now several ranges at once
An allowed list can hold more than one entry. Let's give it three and watch the counts.
CREATE OR REPLACE NETWORK POLICY NPMANY_T164
ALLOWED_IP_LIST = ('192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24');| status |
|---|
| Network policy NPMANY_T164 is created. |
SELECT "name", "entries_in_allowed_ip_list", "entries_in_blocked_ip_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | entries_in_allowed_ip_list | entries_in_blocked_ip_list |
|---|---|---|
| NPMANY_T164 | 3 | 0 |
entries_in_allowed_ip_list reads 3, so SHOW is counting the ranges one by one.
Now the same policy through DESCRIBE.
SELECT "name", "value"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | value |
|---|---|
| ALLOWED_IP_LIST | 192.0.2.0/24,198.51.100.0/24,203.0.113.0/24 |
Still one row. All three ranges came back inside a single comma-separated value.
So SHOW counts and DESCRIBE concatenates. If you are writing something that reads these entries back, that difference decides which statement you want and how much string work you have to do afterwards.
What happens when the value is not an IPv4 address?
Let's try something that is not an address at all.
CREATE OR REPLACE NETWORK POLICY NPBAD_T164
ALLOWED_IP_LIST = ('not.an.ip.address');003043 (22023): SQL compilation error: Not supported IPv4 format for values '[not.an.ip.address]'. Current support format is single IPv4 address with or without CIDR.
003043, and the message quotes the value back at us.
Now a number too big to be an octet.
CREATE OR REPLACE NETWORK POLICY NPBAD2_T164
ALLOWED_IP_LIST = ('999.0.2.1');003043 (22023): SQL compilation error: Not supported IPv4 format for values '[999.0.2.1]'. Current support format is single IPv4 address with or without CIDR.
The same code. Let's check that neither of those left anything behind.
SHOW NETWORK POLICIES LIKE 'NPBAD%';| created_on | name | comment | entries_in_allowed_ip_list | entries_in_blocked_ip_list | entries_in_allowed_network_rules | entries_in_blocked_network_rules |
|---|
SELECT COUNT(*) AS BAD_POLICIES_LEFT
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| BAD_POLICIES_LEFT |
|---|
| 0 |
Nothing. A refused CREATE leaves no half-written object to clean up.
And now an IPv6 address
This is the one where the message earns its keep.
CREATE OR REPLACE NETWORK POLICY NPV6_T164
ALLOWED_IP_LIST = ('2001:db8::/32');003043 (22023): SQL compilation error: Not supported IPv4 format for values '[2001:db8::/32]'. Current support format is single IPv4 address with or without CIDR.
003043 again, and read the second sentence: current support format is single IPv4 address with or without CIDR. A network policy's IP list is IPv4 only, and the error says so in its own words rather than making us guess.
SELECT COUNT(*) AS IPV6_POLICY_ROWS
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| IPV6_POLICY_ROWS |
|---|
| 0 |
So all three of those attempts are the same code, and all three left the account exactly as it was.
Now let's try three policies that should not make sense
These are the three I expected to be told off for. None of them was.
First, a blocked list and no allowed list
CREATE OR REPLACE NETWORK POLICY NPBLOCK_T164
BLOCKED_IP_LIST = ('203.0.113.0/24')
COMMENT = 'episode 164 - blocked only, never applied';| status |
|---|
| Network policy NPBLOCK_T164 is created. |
SELECT "name", "entries_in_allowed_ip_list", "entries_in_blocked_ip_list",
"comment"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | entries_in_allowed_ip_list | entries_in_blocked_ip_list | comment |
|---|---|---|---|
| NPBLOCK_T164 | 0 | 1 | episode 164 - blocked only, never applied |
Made, with 0 in the allowed list and 1 in the blocked list. That is a perfectly reasonable thing to want, so this one is not really a surprise.
SELECT "name", "value"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | value |
|---|---|
| BLOCKED_IP_LIST | 203.0.113.0/24 |
Second, the same range allowed and blocked at once
This is the one. Let's put one range in both lists.
CREATE OR REPLACE NETWORK POLICY NPBOTH_T164
ALLOWED_IP_LIST = ('203.0.113.0/24')
BLOCKED_IP_LIST = ('203.0.113.0/24');| status |
|---|
| Network policy NPBOTH_T164 is created. |
SELECT "name", "entries_in_allowed_ip_list", "entries_in_blocked_ip_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | entries_in_allowed_ip_list | entries_in_blocked_ip_list |
|---|---|---|
| NPBOTH_T164 | 1 | 1 |
Accepted, with 1 in each list. And DESCRIBE reports it twice.
SELECT "name", "value"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | value |
|---|---|
| ALLOWED_IP_LIST | 203.0.113.0/24 |
| BLOCKED_IP_LIST | 203.0.113.0/24 |
Which list wins? I do not know. Finding out means applying this policy to something, and the only thing here is the account these queries ran on. So that question is left open on purpose, and the two rows above are all we have.
Third, a policy with no lists at all
CREATE OR REPLACE NETWORK POLICY NPEMPTY_T164
COMMENT = 'episode 164 - no lists at all';| status |
|---|
| Network policy NPEMPTY_T164 is created. |
SHOW NETWORK POLICIES LIKE 'NPEMPTY\\_T164';| created_on | name | comment | entries_in_allowed_ip_list | entries_in_blocked_ip_list | entries_in_allowed_network_rules | entries_in_blocked_network_rules |
|---|---|---|---|---|---|---|
| 2026-10-06 12:22:10.779000-07:00 | NPEMPTY_T164 | episode 164 - no lists at all | 0 | 0 | 0 | 0 |
Also accepted. All four count columns read 0. It is an object that exists and constrains nothing at all.
SELECT COUNT(*) AS EMPTY_POLICY_ROWS
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| EMPTY_POLICY_ROWS |
|---|
| 1 |
Let's change a policy with ALTER
The three-range policy is still there. Let's check it before we touch it.
SELECT "name", "entries_in_allowed_ip_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | entries_in_allowed_ip_list |
|---|---|
| NPMANY_T164 | 3 |
Three entries. Now let's set the allowed list to one range and see what happens to the other two.
ALTER NETWORK POLICY NPMANY_T164 SET ALLOWED_IP_LIST = ('192.0.2.0/24');| status |
|---|
| Statement executed successfully. |
SELECT "name", "entries_in_allowed_ip_list", "entries_in_blocked_ip_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | entries_in_allowed_ip_list | entries_in_blocked_ip_list |
|---|---|---|
| NPMANY_T164 | 1 | 0 |
One. The other two are gone.
SELECT "name", "value"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | value |
|---|---|
| ALLOWED_IP_LIST | 192.0.2.0/24 |
SET replaces the whole list. It does not add to it. If you want to add a range, you write out every range you want to keep as well.
And the two ALTERs that leave the list alone
Let's set a comment on the same policy.
ALTER NETWORK POLICY NPMANY_T164 SET COMMENT = 'episode 164 - altered once';| status |
|---|
| Statement executed successfully. |
SELECT "name", "comment", "entries_in_allowed_ip_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | comment | entries_in_allowed_ip_list |
|---|---|---|
| NPMANY_T164 | episode 164 - altered once | 1 |
The comment changed and the entry count did not. Now let's unset a blocked list that was never set in the first place.
ALTER NETWORK POLICY NPMANY_T164 UNSET BLOCKED_IP_LIST;| status |
|---|
| Statement executed successfully. |
SELECT "name", "entries_in_allowed_ip_list", "entries_in_blocked_ip_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | entries_in_allowed_ip_list | entries_in_blocked_ip_list |
|---|---|---|
| NPMANY_T164 | 1 | 0 |
Statement executed successfully, and nothing moved. Unsetting something that is already empty is not an error.
Now let's make a network rule
A network rule is a separate object with a separate shape. It has a type, a mode, and a list of values.
CREATE OR REPLACE NETWORK RULE INRULE_T164
TYPE = IPV4
MODE = INGRESS
VALUE_LIST = ('192.0.2.0/24', '198.51.100.0/24')
COMMENT = 'episode 164 - the kind of rule a policy consumes';| status |
|---|
| Network rule INRULE_T164 is created. |
Created. Note that a rule lives in a database and a schema, which a network policy does not.
SHOW NETWORK RULES LIKE 'INRULE\\_T164';| created_on | name | database_name | schema_name | owner | comment | type | mode | entries_in_valuelist | owner_role_type |
|---|---|---|---|---|---|---|---|---|---|
| 2026-10-06 12:22:20.690000-07:00 | INRULE_T164 | DEMO_DB | PUBLIC | ACCOUNTADMIN | episode 164 - the kind of rule a policy consumes | IPV4 | INGRESS | 2 | ROLE |
SELECT "name", "type", "mode", "entries_in_valuelist", "comment"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | type | mode | entries_in_valuelist | comment |
|---|---|---|---|---|
| INRULE_T164 | IPV4 | INGRESS | 2 | episode 164 - the kind of rule a policy consumes |
Type IPV4, mode INGRESS, and entries_in_valuelist reads 2.
And DESCRIBE on a rule gives us the values themselves, comma-separated in one column, the same way it did for a policy.
SELECT "name", "type", "mode", "value_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | type | mode | value_list |
|---|---|---|---|
| INRULE_T164 | IPV4 | INGRESS | 192.0.2.0/24,198.51.100.0/24 |
A type and a mode, and the two are paired
Let's try a mode that is not a mode at all, to see what the refusal tells us.
CREATE OR REPLACE NETWORK RULE BADMODE_T164
TYPE = IPV4
MODE = SIDEWAYS
VALUE_LIST = ('192.0.2.0/24');098502 (22023): The network rule mode must be one of the snowflake supported network rule mode.
098502. The mode must be one of the supported modes, and the message does not say what those are. So let's ask a better question: a real mode, on a real type, in a combination that might not be allowed.
CREATE OR REPLACE NETWORK RULE EGIPV4_T164
TYPE = IPV4
MODE = EGRESS
VALUE_LIST = ('192.0.2.0/24');098511 (22023): SQL compilation error: The network rule mode EGRESS is not supported by the network rule type IPv4. The network rule mode must be one of [INGRESS, POSTGRES_INGRESS, POSTGRES_EGRESS].
098511, and this one is doing our work for us. It names the whole set of modes that IPV4 accepts.
SHOW NETWORK RULES LIKE 'EGIPV4\\_T164';| created_on | name | database_name | schema_name | owner | comment | type | mode | entries_in_valuelist | owner_role_type |
|---|
SELECT COUNT(*) AS EGRESS_IPV4_ROWS
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| EGRESS_IPV4_ROWS |
|---|
| 0 |
Nothing created. Now the other way round: the HOST_PORT type, with the mode that IPV4 wanted.
CREATE OR REPLACE NETWORK RULE OUTRULE_T164
TYPE = HOST_PORT
MODE = INGRESS
VALUE_LIST = ('example.com:443');098511 (22023): SQL compilation error: The network rule mode INGRESS is not supported by the network rule type HOST_PORT. The network rule mode must be one of [EGRESS, DATA_CONNECTIVITY_PROXY_EGRESS].
The same code, naming a different set. So 098511 is worth provoking on purpose: it hands you the pairing table for the type you are holding.
SELECT COUNT(*) AS HOST_PORT_INGRESS_ROWS
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| HOST_PORT_INGRESS_ROWS |
|---|
| 0 |
| Rule type | Modes the refusal named for it |
|---|---|
IPV4 | INGRESS, POSTGRES_INGRESS, POSTGRES_EGRESS |
HOST_PORT | EGRESS, DATA_CONNECTIVITY_PROXY_EGRESS |
Both of those lists are read straight off the two error panes above. The second one is the list Episode 154 reached from the other direction.
Let's build a policy out of a rule instead of addresses
A policy does not have to hold addresses. It can name a rule, and the rule holds the addresses.
CREATE OR REPLACE NETWORK POLICY NPRULE_T164
ALLOWED_NETWORK_RULE_LIST = (INRULE_T164)
COMMENT = 'episode 164 - built from a rule, and still never applied';| status |
|---|
| Network policy NPRULE_T164 is created. |
SELECT "name", "entries_in_allowed_ip_list", "entries_in_blocked_ip_list",
"entries_in_allowed_network_rules", "entries_in_blocked_network_rules"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | entries_in_allowed_ip_list | entries_in_blocked_ip_list | entries_in_allowed_network_rules | entries_in_blocked_network_rules |
|---|---|---|---|---|
| NPRULE_T164 | 0 | 0 | 1 | 0 |
Both IP counts read 0, and entries_in_allowed_network_rules reads 1. That last column is empty on every address-based policy we have made.
And DESCRIBE shows us something we have not seen yet.
SELECT "name", "value"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | value |
|---|---|
| ALLOWED_NETWORK_RULE_LIST | [{"fullyQualifiedRuleName":"DEMO_DB.PUBLIC.INRULE_T164"}] |
JSON, with the fully qualified name of the rule inside it. Database, schema, rule.
One honest correction before we go on
The demo also tried to build a policy out of the egress rule from the last section, and out of a rule name that was never used at all.
-- A policy that names the egress rule from two blocks ago.
CREATE OR REPLACE NETWORK POLICY NPEG_T164
ALLOWED_NETWORK_RULE_LIST = (EGIPV4_T164);-- And a policy that names a rule nobody ever created.
CREATE OR REPLACE NETWORK POLICY NPGHOST_T164
ALLOWED_NETWORK_RULE_LIST = (NO_SUCH_RULE_T164);Both were refused with 002003, and the message in each case is that the named network rule does not exist or is not authorised.
That is not a rule about egress rules inside policies. The egress rule was never created, because the statement that would have made it was refused with 098511 in the last section. So the error is about absence, not about egress, and it would be easy to read it the other way.
The two refusals above are not shown as error panes on this page. Both messages name this account's own identifier, and an error pane here is printed exactly as it came back rather than edited, so the whole pane is left out instead. Nothing about Snowflake's behaviour is missing from the paragraph above it.
SELECT COUNT(*) AS EGRESS_RULE_POLICY_ROWS
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| EGRESS_RULE_POLICY_ROWS |
|---|
| 0 |
And neither attempt left a policy behind.
Can we drop a rule a policy is using?
The rule-based policy is still pointing at our ingress rule. Let's try to drop the rule out from under it.
DROP NETWORK RULE INRULE_T164;098509 (2BP01): Cannot drop Network rule INRULE_T164 as it is associated with some network policies.
098509. Refused, and the message says why: the rule is associated with some network policies.
SHOW NETWORK RULES LIKE 'INRULE\\_T164';| created_on | name | database_name | schema_name | owner | comment | type | mode | entries_in_valuelist | owner_role_type |
|---|---|---|---|---|---|---|---|---|---|
| 2026-10-06 12:22:20.690000-07:00 | INRULE_T164 | DEMO_DB | PUBLIC | ACCOUNTADMIN | episode 164 - the kind of rule a policy consumes | IPV4 | INGRESS | 2 | ROLE |
SELECT COUNT(*) AS RULE_STILL_THERE
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| RULE_STILL_THERE |
|---|
| 1 |
The count says 1. The rule is still there and the drop simply did not happen.
SELECT "name", "value"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | value |
|---|---|
| ALLOWED_NETWORK_RULE_LIST | [{"fullyQualifiedRuleName":"DEMO_DB.PUBLIC.INRULE_T164"}] |
And the policy still names it.
This is worth sitting with for a second. In Episode 157 we dropped a resource monitor that was actively guarding a warehouse, and it just worked, silently. Here the same shape of statement is refused outright. Same question, opposite answers, and nothing about either statement tells you which kind of object you are holding.
Now the names that exist and the names that do not
Let's try to create a policy with a name that is already taken.
CREATE NETWORK POLICY NP_T164 ALLOWED_IP_LIST = ('192.0.2.0/24');002002 (42710): SQL compilation error: Object 'NP_T164' already exists.
002002, object already exists. Now the same statement with IF NOT EXISTS, and a different allowed list and comment inside it.
CREATE NETWORK POLICY IF NOT EXISTS NP_T164
ALLOWED_IP_LIST = ('203.0.113.0/24')
COMMENT = 'episode 164 - this comment should NOT appear';| status |
|---|
| NP_T164 already exists, statement succeeded. |
That succeeded. But look at what the policy says now.
SELECT "name", "comment", "entries_in_allowed_ip_list"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| name | comment | entries_in_allowed_ip_list |
|---|---|---|
| NP_T164 | episode 164 - created, read, dropped, and NEVER APPLIED to anything | 1 |
The original comment, and the original entry count. IF NOT EXISTS did not update anything. It noticed the object was there and stopped.
And a policy that is not there at all
DESCRIBE NETWORK POLICY NO_SUCH_POLICY_T164;002003 (02000): SQL compilation error: Network policy 'NO_SUCH_POLICY_T164' does not exist or not authorized. Your primary role ACCOUNTADMIN or one of your secondary roles must have at least one privilege granted on NETWORK POLICY NO_SUCH_POLICY_T164.
DROP NETWORK POLICY NO_SUCH_POLICY_T164;002003 (02000): SQL compilation error: Network policy 'NO_SUCH_POLICY_T164' does not exist or not authorized. Your primary role ACCOUNTADMIN or one of your secondary roles must have at least one privilege granted on NETWORK POLICY NO_SUCH_POLICY_T164.
The same 002003 from both. And with IF EXISTS the drop goes quiet instead.
DROP NETWORK POLICY IF EXISTS NO_SUCH_POLICY_T164;| status |
|---|
| Drop statement executed successfully (NO_SUCH_POLICY_T164 already dropped). |
The status message tells us it was already dropped, which is a nicer thing to read in a script than a refusal.
One last thing: let's put the account back
Everything above was created, read and is now dropped. Here is the account afterwards.
SHOW NETWORK POLICIES;| created_on | name | comment | entries_in_allowed_ip_list | entries_in_blocked_ip_list | entries_in_allowed_network_rules | entries_in_blocked_network_rules |
|---|
SELECT COUNT(*) AS MY_POLICIES_LEFT
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))
WHERE "name" LIKE '%\\_T164' ESCAPE '\\';| MY_POLICIES_LEFT |
|---|
| 0 |
SHOW NETWORK RULES;| created_on | name | database_name | schema_name | owner | comment | type | mode | entries_in_valuelist | owner_role_type |
|---|
SELECT COUNT(*) AS MY_RULES_LEFT
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))
WHERE "name" LIKE '%\\_T164' ESCAPE '\\';| MY_RULES_LEFT |
|---|
| 0 |
Empty, and both counts read 0. And the parameter we read in the first section, one more time.
SELECT "key", "value", "default", "level"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| key | value | default | level |
|---|---|---|---|
| NETWORK_POLICY |
Still empty. Not one of the policies on this page was ever applied to anything, and that grid is the proof of it.
Key points
- A network policy holds an allowed IP list, a blocked IP list, or a list of network rules. It does nothing until it is applied.
SHOW NETWORK POLICIEScounts the entries.DESCRIBE NETWORK POLICYgives you the entries themselves, comma-separated in one value.- A bare address is stored exactly as written. No
/32is added for you. - An IP list is IPv4 only. Anything else, IPv6 included, is
003043, and nothing is left behind. - A blocked-only policy is accepted. So is a policy with no lists at all. So is the same range in both lists at once.
ALTER ... SETreplaces the whole list.SET COMMENTleaves the list alone, andUNSETon something that was never set succeeds.- A network rule has a
TYPEand aMODE, and the two are paired.098511names the whole set of modes the type allows. - A policy can name a rule instead of an address, and
DESCRIBEreturns JSON with the rule's fully qualified name in it. - A rule that a policy is using cannot be dropped:
098509, and the rule is still there afterwards.
In the next post we move from who can reach the account to what they can see once they are in: masking policies. A policy attached to a column, two roles getting two different answers, and the case where the owner of the table and the policy cannot read their own data.
Every query and every result grid on this page was captured from a live Snowflake account (version 10.36.101) running the demo script for this episode. No policy on this page was applied to the account or to a user, and the NETWORK_POLICY parameter is read empty in the first section and read empty again in the last. Every address used is from a range reserved for documentation, so no real network is named. Two refusals are described in prose rather than shown, because their message text names this account; that is said where it happens. Nothing here is timed and no performance claims are made anywhere in this series. Behaviour follows the Snowflake CREATE NETWORK POLICY documentation.



No comments:
Post a Comment
Note: Only a member of this blog may post a comment.