Hosted by Datacoves - Enterprise DataOps platform with managed dbt Core and Airflow for data transformation and orchestration.
This repository contains the materials and code examples from the Datacove Snowcap webinar held on July 23, 2026.
📚 Full documentation for Snowcap is available at snowcap.datacoves.com.
This workshop demonstrates how to manage Snowflake infrastructure as code using Snowcap, a Snowflake-native, declarative provisioning tool. It walks through defining a database, schemas, and a warehouse in YAML, layering a fine-grained role hierarchy and user grants on top of them, then previewing and applying those definitions directly against a Snowflake account.
Contains the YAML resource definitions that make up the Snowcap configuration:
warehouses.yml- Declares thewarehouseslist variable used by the warehouse object template (currentlywh_transforming, x-small, auto-suspend after 60s)databases.yml- Declares theanalyticsdatabase, thez_db__analyticsrole, and its USAGE grantschemas.yml- Declares theanalytics.stagingandanalytics.martsschemas plus the fine-grainedz_schemas__usage__*andz_tables_views__select__analyticsroles/grants for accessing themroles__functional.yml- Functional roles (analyst,reporter) and the role hierarchy that composes the fine-grainedz_*roles into each oneusers.yml- Declares usersfmercadoandgomeznand grants themACCOUNTADMIN,ORGADMIN,ANALYST, andREPORTER
Reusable Snowcap templates that use for_each over variables to generate resources, roles, and grants consistently:
warehouse.yml- Creates a warehouse, a matchingz_wh__<name>role, and USAGE/MONITOR grants for each entry invar.warehouses
plan.sh- Loads.envand runssnowcap plan, showing what would change without applying itapply.sh- Loads.envand runssnowcap apply, applying the resource definitions to the target Snowflake account.env.sample- Template for the environment variables required to connect to Snowflakesnowcap_test.sql- Sample worksheet for verifying access: switches to theanalystandreporterroles and queries theanalytics.staging/analytics.martsschemas to confirm the granted access works as expected
- Declarative YAML definitions for warehouses, roles, users, and grants
- No state file to manage - Snowcap reads the current state directly from Snowflake
snowcap planto preview changes andsnowcap applyto execute them
- The warehouse object template iterates over the
var.warehouseslist variable - It consistently generates the warehouse plus a matching
z_wh__<name>access-control role and grant - Adding a new warehouse is as simple as adding an entry to the
warehousesvars list
- Fine-grained
z_-prefixed roles scoped to a single privilege/object (e.g.z_db__analytics,z_wh__wh_transforming,z_schemas__usage__marts,z_tables_views__select__analytics) - These fine-grained roles and their grants are defined alongside the resources they protect (
databases.yml,schemas.yml,object_templates/warehouse.yml) - Functional roles (
roles__functional.yml) compose the fine-grained roles into roles a human user is actually granted (analyst,reporter) -analystgets usage on all schemas,reporteris scoped to justmarts
- A Snowflake account with permissions to create databases, schemas, warehouses, roles, and users (e.g.
SECURITYADMIN) uv/uvxinstalled (Snowcap is run viauvx, no separate install required)- A key-pair authentication key configured for your Snowflake user
-
Configure Environment
cp .env.sample .env # Fill in SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, SNOWFLAKE_ROLE, SNOWFLAKE_PRIVATE_KEY_PATH # (SNOWFLAKE_ACCOUNT_PII and SNOWFLAKE_PASSWORD are optional/unused with key-pair auth)
-
Preview Changes
./plan.sh
-
Apply Changes
./apply.sh
The workshop walks through several scenarios:
- Basic Setup: Defining a database, its schemas, and a warehouse in YAML, alongside the fine-grained access-control roles/grants for each
- Role Hierarchy: Building fine-grained (
z_*) roles bottom-up into functional roles (analyst,reporter) that users are actually granted - Templated Resources: Using a
for_eachobject template to add new warehouses without duplicating boilerplate - Plan vs Apply: Comparing
snowcap planoutput againstsnowcap applyto understand exactly what changes before they happen - Verifying Access: Using
snowcap_test.sqlto confirm theanalystandreporterroles can actually query the schemas they were granted
- Sync Resources:
plan.sh/apply.shpass--sync_resources role,grant,role_grant,warehouse,userso Snowcap reconciles (and removes) resources of those types no longer defined in YAML, not just adds new ones - Unsynced Types:
databaseandschemaare intentionally left out of--sync_resources, so Snowcap will create/update them but won't drop a database or schema just because it's removed from YAML - Templates: The
object_templates/warehouse.ymltemplate is driven by thevar.warehousesvariable defined inresources/warehouses.yml
- Snowflake infrastructure and access control can be declared and version-controlled the same way application code is
- Object templates + variables keep role/grant boilerplate DRY as new resources are added
- A layered role hierarchy (fine-grained
z_*roles → functional roles) scales access control cleanly as teams grow snowcap planmakes infrastructure changes reviewable before they touch a live account
This repository serves as a reference implementation for the concepts covered in the Snowcap webinar. Feel free to explore the code and adapt it for your own use cases.