Documentation
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

CREATE SUNDECK FLOW

Creates or replaces a Sundeck Flow. Flows are unique endpoints that can be used to reference your Snowflake accounts. A flow contains zero or more hooks, which are executed in the order that they are declared. When a flow is created, it is assigned a unique hostname. This hostname is used to address the flow until the flow is dropped. To understand more about flows, read the flows overview

See also:
ALTER SUNDECK FLOW, SHOW SUNDECK FLOWS, DESCRIBE SUNDECK FLOW, DROP SUNDECK FLOW

Syntax

CREATE [OR REPLACE] SUNDECK FLOW <flow-id>
    [ COMMENT <comment> ]
    <[hook-definition> [, <hook-definition>]* ]
    [DEFAULT_WAREHOUSE = <warehouse_name>]
    [ONLY ALLOW CONNECTIONS WHERE <network_policy_expression> | ALLOW ALL CONNECTIONS]
;

Where:

<hook-definition> ::=
    [ PRE | POST ] HOOK <hook_instance_name>
    { IF <condition_expression> THEN | ALWAYS }
    <hook_instance_type_name> <hook_configuration>
    [ ENABLED = { TRUE | FALSE } ]
    
<network_policy_expression> ::=
    [LOGIN_NAME = <login_name> | LOGIN_NAME <> <login_name> |
     LOGIN_NAME IN (<login_name>, <login_name>, <login_name>) |
     LOGIN_NAME NOT IN (<login_name>, <login_name>, <login_name>) |
     CLIENT_IP_MATCHES(<IP>) | CLIENT_IP_MATCHES(<CIDR>)]

Parameters

<flow-id>
Specifies the identifier for the flow to create. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive (e.g. “My Object”).
<comment>
Specifies a comment for the flow, which can be used to describe the flow in detail. Comment is a snowflake string literal, it should be enclosed in single quotes.
<hook-definition>
An hook instance definition (see hook parameters below).
<warehouse_name>
The default warehouse to route queries to this warehouse to.
<network_policy_expression>
The optional network policy expression is used to restrict the connections to the broker by login name, client IP (or client CIDR). If no network policy is required then the ALLOW ALL CONNECTIONS clause should be used in the Flow definition.

hook Parameters

<hook_instance_name>
The identifier you want to give the hook instance. Should describe the purpose of this hook for later reference. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive (e.g. “My Object”).
<condition_expression>
The condition expression is a boolean statement that includes one or more conditions along with parentheses, AND, OR, not, etc. Review the conditions reference for a complete overview.
<hook_instance_type_name>
The type of hook to create. Currently available built-in system Pre-hooks and built-in system Post-hooks
<hook_configuration>
A Snowflake object literal that describes the configuration for the provided hook.
ENABLED = { TRUE | FALSE }
Specifies whether hook will be actived or not. If omitted, hook is activated.

Network Policy Parameters

<login_name>
The login name to allow or disallow connections from. Login name is case-insensitive string. See the Snowflake CREATE USER documentation for more information.
<IP>
The IP address to allow or disallow connections from.
<CIDR>
The CIDR block to allow or disallow connections from.

Usage Notes

  • Flow and warehouse identifier follow Snowflake Identifier rules.
  • If you issue CREATE OR REPLACE ... for an existing flow, the unique id of the flow is left unchanged. This allows you to update flow definitions without issuing an ALTER statement.
  • Snowflake variant literal is similar but not the same as JSON. Snowflake variant literals are expressed using brackets and single quotes. Additionally, string literals can be expressed using either single quote literals ' or $$ literals.
  • The network policy expression is used to restrict the connections to the broker. If the network policy expression is not provided, the broker will allow all connections.
  • The network policy is evaluated on each request to the broker. If network policy conditions are not met then the request is rejected.

Examples

CREATE SUNDECK FLOW "My empty flow";
CREATE SUNDECK FLOW EXEC_DASHBOARDS
    PRE HOOK "Check For Things"
      IF SQL_CONTAINS('hello') 
      THEN ROUTE {'toWarehouse':'PRIVATE'}
;
CREATE SUNDECK FLOW REJECT_ALL
    COMMENT 'this flow rejects all queries'
    PRE HOOK "Reject Everything" 
      ALWAYS REJECT {'rejectMessage': 'this flow rejects all queries'}
    ENABLED = TRUE
    DEFAULT_WAREHOUSE = "ALT1"
;