RECOMMEND_ NETWORK_ POLICY¶
Generates a recommended allow-list for an ingress network policy based on successful access within a specified lookback window.
This stored procedure is intended as a starting point if you don’t currently have a network policy or want to redesign an existing one.
The procedure analyzes successful ingress requests, optimizes individual IPs into CIDR blocks, and returns human-readable SQL that administrators can review, refine, and execute.
- See also:
Syntax¶
Arguments¶
Required:
LOOKBACK_DAYS => 'integer'The number of days of successful ingress access to analyze.
Optional:
USER_NAME => 'string'Filters the recommendation to include only traffic from the specified user.
Default: None (includes all users in an account).
Returns¶
Returns human-readable text that contains example SQL statements. The output includes the following information:
- A summary of the number of distinct IP addresses analyzed and the number of CIDR blocks produced.
- An example CREATE OR REPLACE NETWORK RULE statement for an ingress network rule.
- An example CREATE OR REPLACE NETWORK POLICY statement for a network policy that references the rule.
Access control requirements¶
A user must have the SECURITYADMIN role at a minimum to run this stored procedure.
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.
Usage notes¶
- The procedure is read-only with respect to account configuration. It does not create or modify any network rules or policies.
- Recommendations are based only on historical successful ingress. Blocked or failed access is not recommended for allow-listing.
- This procedure can’t determine which IP addresses are correct or safe for your organization. You must validate results with your IT and security teams before executing the generated SQL.
- SQL is provided as text to support copy-paste workflows.
- Output might vary depending on traffic volume and lookback window.
- The USER_NAME filter is optional. When omitted, the recommendation covers all users in an account.
- The procedure enforces a hard limit of 1,000 CIDR blocks. If the recommendation exceeds this limit, the procedure returns an error. To stay within the limit, try a shorter lookback window or filter by user.
- The generated recommendation uses
TYPE = IPV4network rules. If your account receives IPv6 ingress traffic, you may need to create additional network rules withTYPE = IPV6to cover IPv6 addresses. For more information, see Network rules.
Examples¶
Generate a recommended network policy based on the last 1 day of traffic for a specific user:
Generate a recommended network policy based on the last 30 days of traffic for all users: