The following setup allows Alvin to access your Snowflake's metadata and query history, without being able to touch the underlying data.
1. Create Alvin user and role
The first step is to create the role and user. Below we have used alvin_role and alvin_user, but they can be whatever you like. Then, enable access to Snowflake system usage tables.
Alvin also needs data warehouse usage permissions for issuing certain queries. When this step is done, Alvin can access queries from the Snowflake query history.
-- CREATE ALVIN ROLEcreateroleifnotexists alvin_role;-- ALLOW ALVIN ROLE ACCESS TO THE USAGE / ACCOUNT DATAgrant monitor usage on account torole alvin_role;grant imported privileges on all schemas indatabase snowflake torole alvin_role;-- Allow usage on warehousegrant usage on warehouse compute_wh torole alvin_role;-- CREATE ALVIN USERcreateuserifnotexists alvin_user;-- GRANT ALVIN ROLE TO ALVIN USERgrantrole alvin_role to user alvin_user;alteruser alvin_user setpassword='password';
Change snowflake, compute_wh and password and run as is.
2. Grant access to all databases of interest
The final step enables Alvin to access table, view and column names. {db} should be replaced with the database name, and this should be run for all databases of interest. future makes sure that anything created within the database at a later stage is picked up.
grant usage,monitor ondatabase {db} torole alvin_role;grant usage,monitor on all schemas indatabase {db} torole alvin_role;grant usage,monitor on future schemas indatabase {db} torole alvin_role;grantreferenceson future tables indatabase {db} torole alvin_role;grantreferenceson all tables indatabase {db} torole alvin_role;grantreferenceson future materialized views indatabase {db} torole alvin_role;grantreferenceson all materialized views indatabase {db} torole alvin_role;grantreferenceson future views indatabase {db} torole alvin_role;grantreferenceson all views indatabase {db} torole alvin_role;
An important thing to note on this point is that if you have more granular grants, i.e on schemas in these given databases you will need to issue grants separately for all of them too to avoid them being overridden when tables are created, recreated or added to those schemas:
If your organization restricts Snowflake access to a specific set of IP addresses, Alvin will only access your Snowflake through the following IP, add it to your Allowed IP Addresses list:
34.159.141.113