Snowflake roles and grants as code with DCM Projects¶
Verified 2026-11-16. Code: entra-snowflake-reference/snowflake-dcm.
Roles and grants usually build up one GRANT at a time, typed by whoever had
SECURITYADMIN that day. Nobody reviews them, nothing records why they exist,
and removing access means remembering it was there. This guide moves them into
a Git repository. A pull request shows exactly what will change in Snowflake;
merging applies it.
The tool is Snowflake's own DCM Projects (generally available since August
2026). You write DEFINE ROLE, DEFINE DATABASE and GRANT statements,
optionally generated with Jinja from data, and Snowflake works out the
difference from what exists: PLAN shows it, DEPLOY applies it. There is no
state file to host; the project object in Snowflake remembers what it deployed.
flowchart LR
PR["Pull request"] -->|"plan job, as SVC_DCM_PLAN (PLAN only)"| P["DCM PLAN"]
M["Merge to main"] -->|"deploy job, as SVC_DCM_DEPLOY (project owner)"| D["DCM DEPLOY"]
P --> PRJ["DCM project object"]
D --> PRJ
PRJ -->|creates, alters, drops| O["Roles, databases, schemas, database roles, grants"]
Both jobs sign in to Snowflake as Azure managed identities through workload identity federation, the same mechanism as Rotating Snowflake secrets with a managed identity. No secret is stored for either.
What DCM manages, and what it leaves alone¶
- Objects it defines. On deploy, DCM creates what's missing, alters what differs, and drops what is no longer defined. Deleting a database's definition drops the database and its data.
- Grants it deployed. Removing a
GRANTfrom the definitions revokes it on the next deploy. Grants made outside the project are not removed. - Existing objects you add. Defining an object that already exists brings it under the project's management, so later removing that definition drops it. Adopt existing objects deliberately.
- Not users. DCM can grant to a user but doesn't create or manage users.
That last point suits an Entra shop: people should come from Entra anyway.
Entra groups and Snowflake roles¶
An Entra group maps to a Snowflake role only through SCIM provisioning.
With Snowflake's Entra SCIM integration, each group assigned to the Snowflake
enterprise application becomes an account role with the same name, owned by
the AAD_PROVISIONER role, and the group's members are granted it. Nested
groups aren't supported. Without SCIM there is no mapping: External OAuth
reads the user from the token, and the role from its scope or the user's
default role, never from group claims.
A SCIM-created role starts with no privileges. Keep it that way: grant your functional role to it, and keep the privileges in the repository. Entra then decides who is in a group, and the repository decides what the group can do. Entra groups and repository permissions has the SCIM setup and the full chain.
Entra group ──SCIM──▶ account role (owned by AAD_PROVISIONER)
▲ granted_to
functional role (ANALYST) ← defined in the repository
│
▼
database role SANDBOX.CURATED_READ ← defined in the repository
│
▼
privileges on the schema's tables and views
Why DCM over the alternatives¶
| Option | Why not, here |
|---|---|
| Terraform (snowflakedb provider) | Mature, but a state backend to run and a new tool for a team using Bicep |
| Permifrost | YAML for roles and grants, but it revokes everything on a role that its file doesn't list |
| A hand-rolled renderer | Easy to add grants, hard to remove them safely: something must remember what it granted. DCM already does. |
What you need¶
- Snowflake: ACCOUNTADMIN once, to run the bootstrap. The project's own
role needs no ACCOUNTADMIN, SECURITYADMIN or
MANAGE GRANTSafterwards. - Azure: a subscription where you can create two user-assigned managed identities and their federated credentials, and the service principal for Snowflake's Entra application (see the rotation guide).
- GitHub: a repository where you can create environments and variables. Environment branch policies on private repositories need GitHub Pro, Team or Enterprise.
Nothing in this guide needs a warehouse. Plans and deploys, including Jinja rendering, ran with roles that have no warehouse grant at all.
Versions verified¶
| Component | Version |
|---|---|
| Snowflake | 10.41.101 |
| Snowflake CLI | 3.33.0 (bundles snowflake-connector-python 4.8.1) |
| azure-identity | 1.27.0 (needed by the CLI for workload identity) |
| Python | 3.12 |
| Bicep | 0.49.2 |
| GitHub Actions runner | self-hosted, Ubuntu 24.04 |
Pages¶
- Setup. The access model as data, the bootstrap, running a plan by hand, then the pipeline, and a short Hardening section.
- Entra groups and repository permissions. Setting up SCIM so Entra groups become Snowflake roles, what each manifest entry grants, and who in GitHub, Azure and Entra can change access.
- Adopting it incrementally. Rolling it out one database, team and account at a time, without reconciling what exists first.
- Troubleshooting. Every error we hit and what caused it.