Skip to content

About

Snowflake account baseline: role hierarchy, warehouse sizing, zero-copy dev refreshes, DCM Projects and AI gateway governance

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Snowflake platform foundations

The account baseline we start most Snowflake engagements with: roles, warehouses, grants, a nightly dev clone, a DCM project and AI gateway governance, as plain SQL you can read in an afternoon.

What this shows

  • A two-layer role model: access roles hold privileges, functional roles describe people and services, and future grants are set per schema so the model stays true as tables arrive.
  • Warehouses sized per workload, suspending after 60 seconds, each with a resource monitor, plus the queries that tell you whether to size up (spilling) or scale out (queuing).
  • A nightly zero-copy clone of production into dev, with the dev grants re-applied every time.
  • A DCM project that stamps out the same team infrastructure per environment from one Jinja definition.
  • Cortex AI Gateway locked down with ordinary RBAC: USAGE removed from PUBLIC, MONITOR for a cost role, and payload capture with tag-based exemptions.

Read the article

Quick start

Run the scripts in order in a Snowsight worksheet or with the Snowflake CLI. Each script switches to the role it needs with USE ROLE, so you need a user that holds ACCOUNTADMIN for the first run. After that, day-to-day work happens in the functional roles.

Order Script Roles used
1 setup/01_roles.sql USERADMIN, SECURITYADMIN
2 setup/02_warehouses.sql SYSADMIN, SECURITYADMIN, ACCOUNTADMIN
3 setup/03_databases_and_grants.sql SYSADMIN, SECURITYADMIN
4 setup/04_dev_refresh_by_clone.sql ACCOUNTADMIN, SYSADMIN, FR_DEPLOY
5 setup/05_ai_gateway_governance.sql ACCOUNTADMIN
any time monitoring/*.sql a role with access to SNOWFLAKE.ACCOUNT_USAGE

Placeholders to replace before running:

  • sales_db, sales_db_dev and the raw and curated schemas: your own database and schema names.
  • The CREDIT_QUOTA values in 02_warehouses.sql: your monthly budget per workload.
  • The cron schedule and time zone in 04_dev_refresh_by_clone.sql.
  • Ownership for the dev clone: the procedure re-grants on cloned tables, which only works if FR_DEPLOY owns them or holds MANAGE GRANTS. The comment at the top of 04_dev_refresh_by_clone.sql explains the trade-off.
  • Read the comment at the top of 05_ai_gateway_governance.sql before running it. Payload capture stores prompts and responses, so agree it with whoever is responsible for privacy first.

For the DCM project:

  1. Run dcm/bootstrap.sql once to create the deployer role and the project object.
  2. Replace the account_identifier values in dcm/manifest.yml.
  3. From the dcm folder, preview the changes with snow dcm plan --target DEV. Nothing is applied until you deploy.

Repository layout

setup/          numbered account baseline scripts
monitoring/     warehouse sizing and access review queries
dcm/            DCM project: manifest, Jinja definitions and macros, bootstrap
scripts/        render_dcm.py, a local render check for the DCM templates

What is tested

  • CI runs sqlfluff lint (Snowflake dialect, sqlfluff 4.5.0) over every SQL file except the two listed in .sqlfluffignore. That proves the SQL parses and follows a consistent style. It does not prove it runs.
  • setup/05_ai_gateway_governance.sql and the DCM definitions use syntax newer than the linter's dialect, so they are excluded from lint. Every statement in them follows the Snowflake documentation linked at the top of each file.
  • CI renders the DCM templates for every configuration in the manifest with strict undefined variables, so a broken loop or a missing variable fails the build. That is a local check; Snowflake's own PLAN is the real test.
  • None of these scripts have been run against a Snowflake account as part of this repository. Read them, run them in a trial or sandbox account first, and adapt names and budgets to yours.

Further reading

Built by Cloudcentrix, cloud and data engineering in South Africa. https://cloudcentrix.co.za

About

Snowflake account baseline: role hierarchy, warehouse sizing, zero-copy dev refreshes, DCM Projects and AI gateway governance

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages