CREATE GATEWAY¶
Creates a new gateway in the current schema. A gateway enables traffic splitting or shadow traffic across multiple service endpoints.
- See also:
ALTER GATEWAY , DESCRIBE GATEWAY, DROP GATEWAY , SHOW GATEWAYS
Syntax¶
Required parameters¶
nameString that specifies the identifier for the gateway; it must be unique for the schema in which the gateway is created.
FROM SPECIFICATIONSpecifies the gateway specification inline. The specification defines a traffic split or shadow traffic configuration.
For a traffic split gateway, the specification uses the following format:
For a shadow traffic gateway, the specification uses the following format:
Specification parameters¶
typeThe gateway configuration type. Supported values:
traffic_split: Routes requests among target endpoints according to their weights.shadow_traffic: Routes all requests to one primary endpoint and mirrors a percentage of requests to one or more shadow endpoints.
split_typeFor a
traffic_splitgateway, the fixed valuecustom.Don’t specify this parameter for a
shadow_trafficgateway.targetsFor a
traffic_splitgateway, a list of target endpoints to route traffic to. Each target must specify:typeFixed value. Must be set to
endpoint.valueThe fully qualified endpoint name in the format
db.schema.service!endpoint. Each target endpoint must exist.weightThe traffic weight for this endpoint, specified as an integer. All weights must add up to 100.
primaryFor a
shadow_trafficgateway, a list containing exactly one primary endpoint. The primary endpoint receives all requests and returns responses to clients.Don’t specify
weightfor the primary endpoint.shadowFor a
shadow_trafficgateway, a list of one or more shadow endpoints. Each shadow endpoint receives a copy of the percentage of requests specified byweight. Responses from shadow endpoints aren’t returned to clients.Each shadow target uses the same
typeandvaluefields as a traffic split target. Setweightto an integer from 0 through 100. Weights for multiple shadow targets don’t need to add up to 100.
Note
- Maximum number of endpoints per gateway is 5 by default.
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
| Privilege | Object | Notes |
|---|---|---|
| CREATE GATEWAY | Schema | Required to create a gateway in the schema. |
| BIND SERVICE ENDPOINT | Account | Required to bind service endpoints to the gateway. |
| USAGE | Database | Required on the database containing the gateway. |
| USAGE | Schema | Required on the schema containing the gateway. |
| USAGE | Service endpoints | Required on the target service endpoints. Grant the service role ALL_ENDPOINTS_USAGE to provide access. |
To grant the required privileges, use the following commands:
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¶
-
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.
Examples¶
Create a gateway that splits traffic between two service endpoints:
Create or replace a gateway with a new traffic split configuration:
Create a shadow traffic gateway that sends all requests to a primary endpoint and mirrors 10 percent of the requests to a shadow endpoint: