Snowflake Data Export

Overview

This topic explains how to create a Snowflake destination for Data Export.

Prerequisites

To configure the Snowflake Data Export integration, you must have the following prerequisites:

  • You must have the SECURITYADMIN and SYSADMIN roles in Snowflake
  • You need to allow LaunchDarkly’s data transfer service’s static IP address: 35.192.85.117
  • You must know your Snowflake account URL. You can retrieve your Snowflake account/server URL by navigating to the user menu in Snowflake, hovering on Account, then clicking View account details:

The "Copy account URL" option in Snowflake.

The "Copy account URL" option in Snowflake.

Prepare your Snowflake instance

You must prepare a separate Snowflake user and schema for each Launchdarkly project/environment you want to set up for export. The database, warehouse, and role are shared among environments.

First, in Snowflake, create a warehouse and database. You can skip this step if you have already created the warehouse and database below, and are only setting up an additional project/environment.

Snowflake warehouse and database
1begin;
2
3 -- These variables should not be changed
4 set warehouse_name = 'LD_EXPORT_WH'; -- all letters must be uppercase
5 set database_name = 'LD_EXPORT'; -- all letters must be uppercase
6
7 use role sysadmin;
8
9 -- Create a warehouse for data transfer service
10 create warehouse if not exists identifier($warehouse_name)
11 warehouse_size = xsmall
12 warehouse_type = standard
13 auto_suspend = 60
14 auto_resume = true
15 initially_suspended = true;
16
17 -- Create database for data transfer service
18 create database if not exists identifier($database_name);
19
20commit;

Next, create a role with the required privileges on the database and warehouse. You will create a single role for all environments:

Snowflake role
1begin;
2
3 -- These variables should not be changed
4 set role_name = 'LD_EXPORT_ROLE'; -- all letters must be uppercase
5 set warehouse_name = 'LD_EXPORT_WH'; -- all letters must be uppercase
6 set database_name = 'LD_EXPORT'; -- all letters must be uppercase
7
8 -- Change role to securityadmin for role steps
9 use role securityadmin;
10
11 -- Create role for data transfer service
12 create role if not exists identifier($role_name);
13
14 -- Establish SYSADMIN as the parent of the new role. Note: this does not grant the access privileges of SYSADMIN to the new role.
15 grant role identifier($role_name) to role SYSADMIN;
16
17 -- Change role to sysadmin for warehouse / database steps
18 use role sysadmin;
19
20 -- Grant service role access to warehouse
21 grant usage
22 on warehouse identifier($warehouse_name)
23 to role identifier($role_name);
24
25 -- Grant service role access to database
26 grant monitor, usage
27 on database identifier($database_name)
28 to role identifier($role_name);
29
30commit;

Connect your LaunchDarkly environment to Snowflake

In this section, you are working in LaunchDarkly and Snowflake simultaneously. We recommend having two browser windows or tabs open to easily switch back and forth between the two applications.

Begin by configuring the Snowflake Data Export integration in LaunchDarkly:

  1. In LaunchDarkly, navigate to the Integrations page and find “Snowflake Data Export.”
  2. Click Add integration. The “Create a destination” panel appears.
  3. (Optional) Give your integration a human-readable Name.
  4. Choose a Project and environment to export data from.
  5. Copy the Project/environment key to enter into the Snowflake script, below.
  6. Copy the below script and, in Snowflake, paste it into a worksheet to create a Snowflake schema and user. Replace YOUR_LD_PROJ_ENV_KEY with the project/environment key you copied from the previous step:
Snowflake schema and user
1begin;
2
3 -- These variables should not be changed
4 set ld_env_name = '<YOUR_LD_PROJ_ENV_KEY>'; -- key of your LaunchDarkly project and environment
5 set schema_name = CONCAT('EXPORT_', $ld_env_name); -- this schema name will be provided to LaunchDarkly
6 set user_name = CONCAT('LD_EXPORT_USER_', $ld_env_name); -- this user name will be provided to LaunchDarkly
7
8 -- Ensure these match with the warehouse, database, and role names you created earlier
9 set warehouse_name = 'LD_EXPORT_WH';
10 set database_name = 'LD_EXPORT';
11 set role_name = 'LD_EXPORT_ROLE';
12
13 -- Change role to sysadmin for schema steps
14 use role sysadmin;
15
16 -- Create schema for the environment
17 use database identifier($database_name);
18 create schema if not exists identifier($schema_name);
19
20 -- Grant service role access to the schema
21 grant usage, create table
22 on schema identifier($schema_name)
23 to role identifier($role_name);
24
25 -- Change role to securityadmin for user steps
26 use role securityadmin;
27
28 -- Create a user for data transfer service
29 create user if not exists identifier($user_name);
30
31 -- Set default role and warehouse to new user
32 alter user identifier($user_name) set default_role = $role_name;
33 alter user identifier($user_name) set default_warehouse = $warehouse_name;
34
35 grant role identifier($role_name) to user identifier($user_name);
36
37commit;
  1. In Snowflake, run the worksheet. Snowflake creates a new schema and user in your database.
  2. In Snowflake, copy your account URL to use in the next step.
  3. In LaunchDarkly, enter your Snowflake account URL.
  4. Copy the Public key that appears.

The Snowflake Data Export integration with a public key generated.

The Snowflake Data Export integration with a public key generated.
  1. In Snowflake, return to the worksheet you created in step 6. At the end of the worksheet, paste the following, replacing INSERT PUBLIC KEY HERE with the key you copied in step 10:
Adding the public key
1use role securityadmin;
2alter user identifier($user_name) set rsa_public_key=$$
3INSERT PUBLIC KEY HERE
4$$;
  1. Run the above lines in the worksheet.
  2. In LaunchDarkly, test the integration by clicking Test connection.
  3. After reading the Integration Terms and Conditions, check the I have read and agree to the Integration Terms and Conditions checkbox.
  4. Click Save destination. The new Snowflake destination appears in the list of destinations.

Your Snowflake Data Export integration is now complete. To view the different event kinds for Snowflake Data Export destinations, read Snowflake Data Export schema reference.

Built with