Skip to content

Commit 98808df

Browse files
committed
snowflake key pair updates [netlify-build]
1 parent f5e64b4 commit 98808df

File tree

3 files changed

+18
-125
lines changed

3 files changed

+18
-125
lines changed

src/connections/reverse-etl/reverse-etl-source-setup-guides/snowflake-setup.md

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Set up Snowflake as your Reverse ETL source.
99

1010
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.
1111

12-
> success ""
13-
> Segment now supports key-pair authentication for Snowflake Reverse ETL sources.
1412

1513
> info "Snowflake Reverse ETL sources support Segment's dbt extension"
1614
> If you have an existing dbt account with a Git repository, you can use [Segment's dbt extension](/docs/segment-app/extensions/dbt/) to centralize model management and versioning, reduce redundancies, and run CI checks to prevent breaking changes.
@@ -57,9 +55,12 @@ Follow the instructions below to set up the Segment Snowflake connector. Segment
5755
GRANT CREATE SCHEMA ON DATABASE segment_reverse_etl TO ROLE segment_reverse_etl;
5856
GRANT CREATE TABLE ON SCHEMA __segment_reverse_etl TO ROLE segment_reverse_etl;
5957
```
60-
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.
58+
6. Enter and run one of the following code snippets below to create the user Segment uses to run queries.
59+
60+
1. To create a user that authenticates with a key pair, you need to first create the user and assign it a key pair following the instructions in the [Snowflake docs](https://docs.snowflake.com/en/user-guide/key-pair-auth){:target="_blank”}.
61+
62+
2. Execute the following SQL commands:
6163

62-
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:
6364
``` sql
6465
-- create user (key-pair authentication)
6566
CREATE USER segment_reverse_etl_user
@@ -69,21 +70,9 @@ Follow the instructions below to set up the Segment Snowflake connector. Segment
6970
-- role access
7071
GRANT ROLE segment_reverse_etl TO USER segment_reverse_etl_user;
7172
```
72-
73-
To create a user that authenticates with a password, execute the following SQL commands:
74-
```sql
75-
-- create user (password authentication)
76-
CREATE USER segment_reverse_etl_user
77-
MUST_CHANGE_PASSWORD = FALSE
78-
DEFAULT_ROLE = segment_reverse_etl
79-
PASSWORD = 'my_strong_password'; -- Do not use this password
80-
81-
-- role access
82-
GRANT ROLE segment_reverse_etl TO USER segment_reverse_etl_user;
83-
```
8473
7. Add the account information for your source.
85-
5. Click **Test Connection** to test to see if the connection works.
86-
6. Click **Add source** if the test connection is successful.
74+
8. Click **Test Connection** to test to see if the connection works.
75+
9. Click **Add source** if the test connection is successful.
8776

8877

8978
Learn more about the Snowflake Account ID in Snowflake's [Account identifiers](https://docs.snowflake.com/en/user-guide/admin-account-identifier.html){:target="_blank"} documentation.

src/connections/storage/catalog/snowflake/index.md

Lines changed: 4 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -89,35 +89,11 @@ GRANT CREATE SCHEMA ON DATABASE "SEGMENT_EVENTS" TO ROLE "SEGMENT";
8989

9090
### Step 4: Create a user for Segment
9191

92-
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.
92+
Create the user that Segment uses to connect to your warehouse. You can create a user that authenticates with a key pair. For enhanced security, Segment recommends creating a user that authenticates with an encrypted key pair.
9393

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.
103-
104-
```
105-
openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out key_name.p8
106-
```
107-
108-
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.
111-
112-
```
113-
openssl rsa -in key_name.p8 -pubout -out public_key_name.pub
114-
```
115-
116-
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.
94+
To create a user that authenticates with a key pair:
95+
1. Create the user and assign it a key pair by following the instructions in the [Snowflake docs](https://docs.snowflake.com/en/user-guide/key-pair-auth){:target="_blank"}.
96+
2. Create a new user by executing the following SQL command, replacing the public key value with the key you previously generated.
12197

12298
``` sql
12399
CREATE USER SEGMENT_USER
@@ -126,17 +102,6 @@ CREATE USER SEGMENT_USER
126102
GRANT ROLE "SEGMENT" TO USER "SEGMENT_USER";
127103
```
128104

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.
131-
132-
```sql
133-
CREATE USER "SEGMENT_USER"
134-
MUST_CHANGE_PASSWORD = FALSE
135-
DEFAULT_ROLE = "SEGMENT"
136-
PASSWORD = "my_strong_password"; -- Do not use this password
137-
GRANT ROLE "SEGMENT" TO USER "SEGMENT_USER";
138-
```
139-
140105
### Step 5: Test the user and credentials
141106

142107
Before you continue, test and validate the new user and credentials. After you verify the new credentials, you can connect Snowflake to Segment.
@@ -157,67 +122,6 @@ For accounts outside the US, the account ID includes the region. You can find yo
157122

158123
For example, if your web address is `https://myaccountname.snowflakecomputing.com/console#/internal/worksheet`, your account name would be `myaccountname`.
159124

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.
162-
To install SnowSQL and verify your accounts:
163-
164-
1. Download [SnowSQL](https://docs.snowflake.com/en/user-guide/snowsql){:target="_blank"}
165-
2. Open the Installer and follow instructions.
166-
3. When the installation is complete, run the following command, replacing "account" and "user" with your Snowflake Account ID and username:
167-
168-
```
169-
snowsql -a <account> -u <user>
170-
```
171-
172-
For accounts outside the US, the account ID includes the region. You can find your account name from the browser address string.
173-
174-
For example, if your web address is `https://myaccountname.snowflakecomputing.com/console#/internal/worksheet`, your account name would be `myaccountname`.
175-
176-
You can also find part of your account name by running the following query on your worksheet in Snowflake:
177-
178-
```sql
179-
SELECT CURRENT_ACCOUNT();
180-
```
181-
4. Enter password when prompted.
182-
183-
5. Run the following:
184-
185-
```
186-
~$ snowsql --accountname myb10 --username SEGMENT_USER
187-
Password:
188-
* SnowSQL * v1.1.46
189-
Type SQL statements or !help
190-
SEGMENT_USER#(no warehouse)@(no database).(no schema)>SELECT 1;
191-
+---+
192-
| 1 |
193-
|---|
194-
| 1 |
195-
+---+
196-
1 Row(s) produced. Time Elapsed: 0.093s
197-
SEGMENT_USER#(no warehouse)@(no database).(no schema)>USE WAREHOUSE "SEGMENT_WAREHOUSE";
198-
+----------------------------------+
199-
| status |
200-
|----------------------------------|
201-
| Statement executed successfully. |
202-
+----------------------------------+
203-
1 Row(s) produced. Time Elapsed: 0.118s
204-
SEGMENT_USER#SEGMENT_WAREHOUSE@(no database).(no schema)>USE DATABASE "SEGMENT_EVENTS";
205-
+----------------------------------+
206-
| status |
207-
|----------------------------------|
208-
| Statement executed successfully. |
209-
+----------------------------------+
210-
1 Row(s) produced. Time Elapsed: 0.130s
211-
SEGMENT_USER#SEGMENT_WAREHOUSE@SEGMENT_EVENTS.(no schema)>!exit
212-
```
213-
214-
If you would like to use the web interface, switch to the new role for the Segment user, create a new Worksheet and execute:
215-
216-
```sql
217-
SELECT 1;
218-
USE WAREHOUSE "SEGMENT_WAREHOUSE";
219-
USE DATABASE "SEGMENT_EVENTS";
220-
```
221125

222126
### Step 6: Connect Snowflake to Segment
223127

src/unify/data-graph/setup-guides/snowflake-setup.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ To connect your warehouse to the Data Graph:
150150
2. Click **Connect warehouse**.
151151
3. Select Snowflake as your warehouse type.
152152
4. Enter your warehouse credentials. Segment requires the following settings to connect to your Snowflake warehouse:
153-
- **Account ID**: The Snowflake account ID that uniquely identifies your organization account
154-
- **Database**: The only database that Segment requires write access to in order to create tables for internal bookkeeping. This database is referred to as `segment_connection_db` in the script below
155-
- **Warehouse**: The [warehouse](https://docs.snowflake.com/en/user-guide/warehouses){:target="_blank”} in your Snowflake account that you want to use for Segment to run the SQL queries. This warehouse is referred to as `segment_connection_warehouse` in the script below
156-
- **Username**: The Snowflake user that Segment uses to run SQL in your warehouse. This user is referred to as `segment_connection_username` in the script below
157-
- **Authentication**: There are 2 supported authentication methods:
158-
- **Key Pair**: This is the recommended method of authentication. You would need to first create the user and assign it a key pair following the instructions in the [Snowflake docs](https://docs.snowflake.com/en/user-guide/key-pair-auth){:target="_blank"}. Then, follow the Segment docs above to set up Snowflake permissions and set the `segment_connections_username` variable in the SQL script to the user you just created
159-
- **Password**: The password of the user above. This password is referred to as `segment_connection_password` in the script below
153+
- **Account ID**: The Snowflake account ID that uniquely identifies your organization account.
154+
- **Database**: The only database that Segment requires write access to in order to create tables for internal bookkeeping. This database is referred to as `segment_connection_db` in the script below.
155+
- **Warehouse**: The [warehouse](https://docs.snowflake.com/en/user-guide/warehouses){:target="_blank”} in your Snowflake account that you want to use for Segment to run the SQL queries. This warehouse is referred to as `segment_connection_warehouse` in the script below.
156+
- **Username**: The Snowflake user that Segment uses to run SQL in your warehouse. This user is referred to as `segment_connection_username` in the script below.
157+
- **Authentication**: Snowflake only supports authentication using a key pair:
158+
- **Key Pair**: You need to first create the user and assign it a key pair following the instructions in the [Snowflake docs](https://docs.snowflake.com/en/user-guide/key-pair-auth){:target="_blank"}. Then, set the `segment_connections_username` variable in the SQL script to the user you just created.
159+
160160

161161
5. Test your connection, then click Save.
162162

0 commit comments

Comments
 (0)