-- Create core Sidecar infra: role, user, databaseuse role ACCOUNTADMIN;create role if not exists SIDECAR_ROLE;create user if not exists SIDECAR_USER;grant role SIDECAR_ROLE to user SIDECAR_USER;alter user SIDECAR_USER set default_role = SIDECAR_ROLE;alter user SIDECAR_USER set type = service;alter user SIDECAR_USER set password = 'strong_password_here';set default_warehouse = '<warehouse>'; -- existing or SIDECAR_WH-- So that any SYSADMIN user can use the Sidecar tablesgrant role SIDECAR_ROLE to role SYSADMIN;-- Create database for Sidecarcreate database if not exists SIDECAR_DATABASE;-- Grant Sidecar role access to Sidecar warehousegrant all on warehouse SIDECAR_DATABASE to role SIDECAR_ROLE;-- Grant Sidecar access to Sidecar databasegrant all on database SIDECAR_DATABASE to role SIDECAR_ROLE;grant SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES on all tables in database SIDECAR_DATABASE to role SIDECAR_ROLE;grant SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES on future tables in database SIDECAR_DATABASE to role SIDECAR_ROLE;grant SELECT on all views in database SIDECAR_DATABASE to role SIDECAR_ROLE;grant SELECT on future views in database SIDECAR_DATABASE to role SIDECAR_ROLE;grant USAGE, MONITOR on all schemas in database SIDECAR_DATABASE to role SIDECAR_ROLE;grant USAGE, MONITOR on future schemas in database SIDECAR_DATABASE to role SIDECAR_ROLE;
3. Add key-pair authentication to the Sidecar user
Starting November 2025, Snowflake requires all service users to use key-pair authentication. Sidecar recommends using key-pair when setting up a user for Sidecar.
4. Grant Sidecar access to Snowflake system views and warehouse monitoring
grant IMPORTED PRIVILEGES on database SNOWFLAKE to role SIDECAR_ROLE;grant CREATE DATABASE on ACCOUNT to role SIDECAR_ROLE;grant MANAGE WAREHOUSES ON ACCOUNT to role SIDECAR_ROLE;
5. Grant Sidecar access to databases you’d like to monitor
-- Use SHOW DATABASES to get a list of all your databases-- Repeat for all databases you'd like Sidecar to monitorgrant usage, monitor on DATABASE <database> TO ROLE SIDECAR_ROLE;grant usage, monitor on all schemas IN DATABASE <database> to role SIDECAR_ROLE;grant usage, monitor on future schemas IN DATABASE <database> to role SIDECAR_ROLE;
6. Grant Sidecar access to schemas you’d like to monitor
-- Repeat for all databases + schemas you'd like Sidecar to monitorgrant select on all tables in schema <database>.<schema> to role SIDECAR_ROLE;grant select on future tables in schema <database>.<schema> to role SIDECAR_ROLE;grant select on all views in schema <database>.<schema> to role SIDECAR_ROLE;grant select on future views in schema <database>.<schema> to role SIDECAR_ROLE;
Helper script: generate grant statements for all schemas
This command generates the SQL statements for all (database.schema) pairs. You must grant access to databases before running this (Step 5).
SELECT 'GRANT SELECT ON ' || k.scope || ' ' || o.obj || ' IN SCHEMA "' || REPLACE(s.catalog_name, '"','""') || '"."' || REPLACE(s.schema_name, '"','""') || '" TO ROLE SIDECAR_ROLE;' AS grant_stmtFROM SNOWFLAKE.ACCOUNT_USAGE.SCHEMATA AS s , LATERAL (SELECT 'ALL' AS scope UNION ALL SELECT 'FUTURE') AS k , LATERAL (SELECT 'TABLES' AS obj UNION ALL SELECT 'VIEWS') AS oWHERE s.deleted IS NULL AND s.catalog_name <> 'SNOWFLAKE' AND NOT STARTSWITH(s.catalog_name, 'USER$')ORDER BY s.catalog_name, s.schema_name, o.obj, k.scope;
Alternative: database-level grants
For customers who only wish to grant database-level privileges, use the following. Note: Database-level privileges are ignored if schema-level privileges are granted to other users, so this approach may lead to inconsistent access.
SELECT 'GRANT SELECT ON ' || k.scope || ' ' || o.obj || ' IN DATABASE "' || REPLACE(d.database_name, '"','""') || '" TO ROLE SIDECAR_ROLE;' AS grant_stmtFROM SNOWFLAKE.ACCOUNT_USAGE.DATABASES AS d , LATERAL (SELECT 'ALL' AS scope UNION ALL SELECT 'FUTURE') AS k , LATERAL (SELECT 'TABLES' AS obj UNION ALL SELECT 'VIEWS') AS oWHERE d.deleted IS NULL AND d.database_name <> 'SNOWFLAKE' AND NOT STARTSWITH(d.database_name, 'USER$')ORDER BY d.database_name, o.obj, k.scope;