Create Snowflake User and Privileges
In this section, we'll take care of having the prerequisites for creating a Snowflake - Seemore integration.
Create a role
💭 Create a role in Snowflake using the following commands:
-- Switch to the ACCOUNTADMIN role to perform administrative tasks such as creating warehouses.
USE ROLE ACCOUNTADMIN;
CREATE ROLE IF NOT EXISTS seemore_user_role;
GRANT OPERATE, USAGE ON WAREHOUSE "<warehouse_name>" TO ROLE seemore_user_role;Replace
<warehouse_name>with the default warehouse to use when running the Seemore snowflake "metadata fetcher".
Create a user
To create a user with a password, replace <password> and run the following:
CREATE USER IF NOT EXISTS seemore_user password='<password>' default_role=seemore_user_role default_warehouse='<warehouse_name>' display_name='SeemoreData';Key-pair authentication (Recommended)
To use key-pair authentication instead of password:
Generate the private key
To start, open a terminal window and generate a private key. You can generate either an encrypted version of the private key or an unencrypted version of the private key. To generate an unencrypted version, use the following command:
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocryptTo generate an encrypted version, use the following command, which omits -nocrypt:
openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out rsa_key.p8Generate a public key
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pubStore the private and public keys securely !!!
Assign the public key to a Snowflake user
ALTER USER example_user SET RSA_PUBLIC_KEY='MIIBIjANBgkqh...';For more details access official Snoflake documentation.
Grant role to user
To grant the user_role to the new user:
GRANT ROLE seemore_user_role TO USER seemore_user;Grant Privileges
In order to fetch metadata from snowflake, Seemore needs access only to SNOWFLAKE using GRANT IMPORTED PRIVILEGES.
-- Grant the role permission to import metadata from the Snowflake database.
GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE seemore_user_role;
-- Grant the role permission to monitor usage on the entire account.
GRANT MONITOR USAGE ON ACCOUNT TO ROLE seemore_user_role;Comprehensive Setup Script
This script encompasses the entire setup process, including creating a dedicated warehouse for Seemore, establishing roles, creating a user, and assigning the necessary privileges for operations and monitoring. Please make sure to replace <Your Password>.
If you don't need the warehouse just comment out the (lines 8-19), and replace seemore_warehouse (line 26) with your warehouse.
Add additional warehouse data permissions
Seemore needs additional permissions to read warehouse configurations such as timeouts.
Per warehouse we need USAGEpermissions.
DECLARE
res RESULTSET DEFAULT (SHOW WAREHOUSES);
warehouse_name STRING;
sql_command STRING;
BEGIN
FOR warehouse IN res DO
warehouse_name := warehouse."name";
sql_command := 'GRANT USAGE ON WAREHOUSE "' || warehouse_name || '" TO ROLE ' || 'seemore_user_role' || ';';
EXECUTE IMMEDIATE sql_command;
END FOR;
END;Seemore needs additional permissions to modify warehouse configurations such as auto suspend.
Per warehouse we need MODIFY permissions.
DECLARE
res RESULTSET DEFAULT (SHOW WAREHOUSES);
warehouse_name STRING;
sql_command STRING;
BEGIN
FOR warehouse IN res DO
warehouse_name := warehouse."name";
sql_command := 'GRANT MODIFY ON WAREHOUSE "' || warehouse_name || '" TO ROLE ' || 'seemore_user_role' || ';';
EXECUTE IMMEDIATE sql_command;
END FOR;
END;Monitoring Additional Snowflake Services
Streams, Dynamic tables & Materialized Views
Create (or use) a dedicated database and schema to house the procedure:
CREATE DATABASE IF NOT EXISTS seemore; CREATE SCHEMA IF NOT EXISTS seemore.utils;Grant the necessary privileges to
seemore_user_roleso it can execute the procedure and view the results:GRANT USAGE ON DATABASE seemore TO ROLE seemore_user_role; GRANT USAGE ON SCHEMA seemore.utils TO ROLE seemore_user_role;(Adjust privileges if additional permissions are required by your security model.)
Use a role with `ACCOUNTADMIN` to create or replace the procedure. This high-level role is needed to grant the procedure enough access to list all streams.
Create (or replace) the stored procedure with
EXECUTE AS OWNER. This setting ensures the procedure runs with the privileges of the owner (the role that created it). That way, even if the caller’s role does not have the privileges to see all streams directly, the procedure can still return the entire list:
Auto clustering recommendations
Permissions to Auto Clustering monitoring and recommendations
By creating the below procedures and give Seemore the access to it we will be able to help you cluster your tables in a more efficient way and also improve Snowflake's auto-clustering feature, Without the need of exposing data at all.
First, create the Seemore database and schema if not exists:
CREATE DATABASE IF NOT EXISTS seemore;
CREATE SCHEMA IF NOT EXISTS seemore.utils;
GRANT USAGE ON DATABASE seemore TO ROLE seemore_user_role;
GRANT USAGE ON SCHEMA seemore.utils TO ROLE seemore_user_role;Its important to create the following procedures using `ACCOUNTADMIN` role. This high-level role is needed to grant the procedure access to all the tables clustering information.
GET_CLUSTERING_INFO - Create a procedure that gives Seemore an ability to access snowflake clustering information method, which allows us optimizing our recommendation of clustering columns candidates, based on actual cardinality stats of the tables.
GET_CLUSTERING_COST_ESTIMATE Create a procedure that gives Seemore an access to auto clustering cost estimate method , So Seemore can use it for estimating the cost of turning on auto clustering based on out recommendations.
Allowlist the Seemore IP
If you are using the IP allowlist in your Snowflake instance, you must add the Seemore IP to the allowlist.
(If you are not using the IP Allowlist in your Snowflake instance, you can skip this step.)
CREATE NETWORK POLICY seemore_production ALLOWED_IP_LIST=('3.78.110.132', '3.73.171.134');
ALTER USER seemore_user SET NETWORK_POLICY = seemore_production;Last updated
