You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/reverse-etl/reverse-etl-source-setup-guides/snowflake-setup.md
+19-4Lines changed: 19 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,13 @@ redirect_from:
7
7
8
8
Set up Snowflake as your Reverse ETL source.
9
9
10
-
At a high level, when you set up Snowflake for Reverse ETL, the configured user/role needs read permissions for any resources (databases, schemas, tables) the query needs to access. Segment keeps track of changes to your query results with a managed schema (`__SEGMENT_REVERSE_ETL`), which requires the configured user to allow write permissions for that schema.
10
+
At a high level, when you set up Snowflake for Reverse ETL, the configured user/role needs read permissions for any resources (databases, schemas, tables) the query needs to access. Segment keeps track of changes to your query results with a managed schema <br>(`__SEGMENT_REVERSE_ETL`), which requires the configured user to allow write permissions for that schema.
11
+
12
+
> success ""
13
+
> Segment now supports key-pair authentication for Snowflake Reverse ETL sources. Key-pair authentication is available for Business Tier users only.
11
14
12
15
## Set up guide
13
-
Follow the instructions below to set up the Segment Snowflake connector. Segment recommends you use the `ACCOUNTADMIN` role to execute all the commands below.
16
+
Follow the instructions below to set up the Segment Snowflake connector. Segment recommends you use the `ACCOUNTADMIN` role to execute all the commands below, and that you create a user that authenticates with an encrypted key pair.
14
17
15
18
1. Log in to your Snowflake account.
16
19
2. Navigate to *Worksheets*.
@@ -47,10 +50,22 @@ Follow the instructions below to set up the Segment Snowflake connector. Segment
47
50
GRANT USAGE ON DATABASE segment_reverse_etl TO ROLE segment_reverse_etl;
48
51
GRANT CREATE SCHEMA ON DATABASE segment_reverse_etl TO ROLE segment_reverse_etl;
49
52
```
50
-
6. Enter and run the code below to create the username and password combination that will be used to execute queries. Make sure to enter your password where it says `my_strong_password`.
53
+
6. Enter and run one of the following code snippets below to create the user Segment uses to run queries. For added security, Segment recommends creating a user that authenticates using a key pair.
54
+
55
+
To create a user that authenticates with a key pair, [create a key pair](https://docs.snowflake.com/en/user-guide/key-pair-auth#configuring-key-pair-authentication){:target="_blank”} and then execute the following SQL commands:
56
+
```sql
57
+
-- create user (key-pair authentication)
58
+
CREATEUSERsegment_reverse_etl_user
59
+
DEFAULT_ROLE = segment_reverse_etl
60
+
RSA_PUBLIC_KEY ='enter your public key';
61
+
62
+
-- role access
63
+
GRANT ROLE segment_reverse_etl TO USER segment_reverse_etl_user;
64
+
```
51
65
66
+
To create a user that authenticates with a password, execute the following SQL commands:
Copy file name to clipboardExpand all lines: src/connections/storage/catalog/snowflake/index.md
+86-7Lines changed: 86 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,48 @@ GRANT CREATE SCHEMA ON DATABASE "SEGMENT_EVENTS" TO ROLE "SEGMENT";
86
86
87
87
### Step 4: Create a user for Segment
88
88
89
-
Create the user that Segment uses to connect to your warehouse. Be sure to use a strong, unique password.
89
+
Create the user that Segment uses to connect to your warehouse. You can create a user that authenticates with a key pair, or you can create a user that authenticates using a password. For enhanced security, Segment recommends creating a user that authenticates with an encrypted key pair.
90
+
91
+
> info "Key-pair authentication restricted to Business Tier users only"
92
+
> Users on other plans can authenticate with Snowflake using a [username and password](#create-a-user-that-authenticates-with-a-username-and-password).
93
+
94
+
#### Create a user that authenticates with a key pair
95
+
If you are creating a user that will use a key pair to authenticate, you first must create a public key and then can create a new user.
96
+
97
+
##### Generate keys
98
+
99
+
To start, open a terminal window and generate a private key by running the following command, replacing `key_name` with the name you'd like to give the key. The command generates a private key in PEM format, and will prompt you to enter a passphrase. Write down or remember this passphrase, as you will need it when creating your Segment user and configuring your destination in the Segment app.
100
+
101
+
> success ""
102
+
> If you want to generate an unencrypted private key, append `-nocrypt` to the end of the command.
After you've created the private key, save the file to a local directory. You'll need to upload the .p8 file to the Segment app when you create your Snowflake destination.
109
+
110
+
Next, generate your public key by running the following command, replacing `key_name.p8` with the name of the private key that you previously created and `public_key_name` with the name of your new public key.
After you've created the public key, save the file to a local directory.
117
+
118
+
##### Generate a new user and assign the key to them
119
+
120
+
Now, create a new user by executing the following SQL command, replacing the public key value with the key you previously generated.
121
+
122
+
```sql
123
+
CREATEUSERSEGMENT_USER
124
+
DEFAULT_ROLE = SEGMENT
125
+
RSA_PUBLIC_KEY ='enter your public key';
126
+
GRANT ROLE "SEGMENT" TO USER "SEGMENT_USER";
127
+
```
128
+
129
+
#### Create a user that authenticates with a username and password
130
+
If you are creating a user that will use a username and password to authenticate, execute the following SQL command. Be sure to set a strong, unique password.
90
131
91
132
```sql
92
133
CREATEUSER "SEGMENT_USER"
@@ -98,13 +139,30 @@ GRANT ROLE "SEGMENT" TO USER "SEGMENT_USER";
98
139
99
140
### Step 5: Test the user and credentials
100
141
101
-
Before you continue, test and validate the new user and credentials. When you can run the following commands successfully, you can connect Snowflake to Segment.
142
+
Before you continue, test and validate the new user and credentials. After you verify the new credentials, you can connect Snowflake to Segment.
102
143
144
+
#### Test a key pair
103
145
Segment uses [SnowSQL](https://docs.snowflake.com/en/user-guide/snowsql){:target="_blank"} to run these verification steps.
3. When the installation is complete, run the following command, replacing "account", "username", and "path_to_the_rsa_key_encrypted.p8" with your Snowflake Account ID, username, and path to your private RSA key:
For accounts outside the US, the account ID includes the region. You can find your account name from the browser address string.
157
+
158
+
For example, if your web address is `https://myaccountname.snowflakecomputing.com/console#/internal/worksheet`, your account name would be `myaccountname`.
159
+
160
+
#### Test a username and password
161
+
Segment uses [SnowSQL](https://docs.snowflake.com/en/user-guide/snowsql){:target="_blank"} to run these verification steps.
3. When the installation is complete, run the following command, replacing "account" and "user" with your Snowflake Account ID and username:
109
167
110
168
```
@@ -167,12 +225,23 @@ After configuring your Snowflake resources, connect them to Segment.
167
225
168
226
1. In the Segment App, select Add Destination.
169
227
2. Search for and select "Snowflake".
170
-
3. Add your credentials as follows:
171
-
-**User**: The user name that you created in [Step 4: Create a user for Segment](#step-4-create-user-for-segment)
172
-
-**Password**: The password that you set in [Step 4: Create a user for Segment](#step-4-create-user-for-segment)
228
+
3. Enter a name for your destination.
229
+
4. Enter your Snowflake credentials as follows:
173
230
-**Account**: The account id of your cluster, not the url (for example, url: `my-business.snowflakecomputing.com`, account-id: `my-business`. **Note:** If you are using Snowflake on AWS, the account id includes the region. For example, your url might be: `my-business.us-east-1.snowflakecomputing.com/` and your account-id would be: `my-business.us-east-1`)
174
-
-**Database**: The database name that you created in [Step 2: Create database](#step-2-create-database)
175
231
-**Warehouse**: The name of the warehouse that you created in [Step 1: Create a virtual warehouse](#step-1-create-a-virtual-warehouse)
232
+
-**Database**: The database name that you created in [Step 2: Create database](#step-2-create-database)
233
+
-**Username**: The username that you created in [Step 4: Create a user for Segment](#step-4-create-user-for-segment)
234
+
-**Authentication method**: Select the authentication method that you used when creating a user in [Step 4: Create a user for Segment](#step-4-create-user-for-segment). You can select either Key pair or Password.
235
+
236
+
If you selected Key pair as your authentication method:
237
+
-**Private key**: Upload your private key (stored in .p8 format) that you created in [Step 4: Create a user for Segment](#step-4-create-user-for-segment)
238
+
-**Passphrase**_(Optional)_ : If you created an encrypted key, enter the passphrase you created in [Step 4: Create a user for Segment](#step-4-create-user-for-segment)
239
+
240
+
> info "Segment supports uploading one key at a time"
241
+
> Although you can create up to two keys in Snowflake, Segment only supports authenticating with one key at a time. To change the key that is in Segment, return to your Snowflake destination's settings and upload a new key in the **Private Key** field.
242
+
243
+
If you selected Password as your authentication method:
244
+
-**Password**: The password that you set in [Step 4: Create a user for Segment](#step-4-create-user-for-segment)
176
245
177
246
## Security
178
247
@@ -188,6 +257,12 @@ At this time, the Segment Snowflake destination is not compatible with Snowflake
188
257
189
258
## Best Practices
190
259
260
+
### Key pair authentication
261
+
262
+
Segment recommends that you authenticate with your Snowflake warehouse using an encrypted key pair. Key-pair authentication uses PKCS#8 private keys, which are typically exchanged in the PEM base64-encoded format.
263
+
264
+
Although you can create up to two keys in Snowflake, Segment only supports authenticating with one key at a time. To change the key that is in Segment, return to your Snowflake destination's settings and upload a new key in the **Private Key** field.
265
+
191
266
### Auto Suspend and Auto Resume
192
267
193
268
Set `AUTO_SUSPEND` to ~10 minutes in the UI (or 600 if using SQL) to minimize the credit consumption of Segment's syncing process.
@@ -249,3 +324,7 @@ Queuing - you can use a different Warehouse for Segment, or use the recommendati
### I'm encountering a "JWT token is invalid" error. What do I do?
329
+
330
+
For more information about troubleshooting a `JWT token is invalid` error, see Snowflake's [Key Pair Authentication: Troubleshooting](https://docs.snowflake.com/user-guide/key-pair-auth-troubleshooting){:target="_blank”} documentation.
0 commit comments