SharedDatabase¶
Snowflake Documentation | Snowcap CLI label: shared database
A SharedDatabase is the consumer side of a Snowflake share or Marketplace
listing: CREATE DATABASE <name> FROM SHARE <provider_account>.<share_name>.
It's a polymorphic sibling of Database — declared under the
same databases: key, distinguished by the presence of from_share. Because
Snowflake replicates the provider's schemas, tables, and other objects into
the consumer account, shared databases are read-only: snowcap cannot add
schemas, tags, or params to them the way it can for a regular Database.
Examples¶
YAML¶
Python¶
Fields¶
name(string, required) - The name of the database.from_share(string, required) - The<provider_account>.<share_name>the database is created from. Changing this on an existing shared database is not supported byplan/apply— it errors at plan time. Drop and recreate the database manually instead.owner(string or Role) - Pinned to"ACCOUNTADMIN". Snowflake preventsGRANT OWNERSHIPon an imported database, so a custom owner is rejected at plan time. Omit the field.
Full example: importing a Gong share¶
A common pattern is importing a Marketplace or direct share, then handing a scoped role access to it:
databases:
- name: gong
from_share: provider_account.share_name
roles:
- name: gong_r
grants:
- priv: IMPORTED PRIVILEGES
on_database: gong
to: gong_r
role_grants:
- role: gong_r
to_role: data_engineer
Which is equivalent to:
CREATE DATABASE gong FROM SHARE provider_account.share_name;
CREATE ROLE gong_r;
GRANT IMPORTED PRIVILEGES ON DATABASE gong TO ROLE gong_r;
GRANT ROLE gong_r TO ROLE data_engineer;
Gotchas¶
- Shared databases are read-only — snowcap does not manage schemas, params, or tags on them.
CREATE DATABASE ... FROM SHARErequires the account-levelIMPORT SHAREprivilege, which onlyACCOUNTADMINholds by default. Snowcap runs the creation asACCOUNTADMIN.- Ownership of a shared database cannot change: imported databases are
read-only in the consumer account, and Snowflake prevents
GRANT OWNERSHIPon them. Snowcap pinsownertoACCOUNTADMINand does not track it for drift. IMPORTED PRIVILEGESis the only privilege that can be granted on a shared database. It cannot be grantedWITH GRANT OPTION, and it can only be granted to account roles, not database roles.- Snowflake's
SHOW GRANTSreportsIMPORTED PRIVILEGESgrants on shared databases asUSAGE— snowcap's fetch logic accounts for this quirk, soplan/applystill converge correctly. - Changing
from_shareon an existing shared database is not supported byplan/apply— it errors at plan time. Drop and recreate the database manually if you need to point it at a different share.