Replies: 3 comments 20 replies
-
Ok, I see two different problems mentioned here. (1) Creating database roles and granting database roles to shares How we could possibly implement it in SnowDDL: # <DB>/database_role.yaml
<database_role_name>:
grants: <similar_to_share_grants> And this role can be granted to share using normal grants from here: https://docs.snowddl.com/basic/yaml-configs/share-outbound test_share:
accounts: <list_of_accounts>
grants:
DATABASE_ROLE:USAGE:
- <database_role_1>
- <database_role_2> Object type (2) Granting objects created by DBT to shares As far as I know, it is not possible to use future grants with shares. It includes direct grants to share and indirect grants via database roles. Please see usage notes here: https://docs.snowflake.com/en/sql-reference/sql/grant-database-role-share#usage-notes If future grants are not supported, it means DBT does not work well with shares, since it wants to re-create objects. Even if we add an explicit In my view, the best possible solution is to ditch DBT. At this point it creates more problem than it solves. Shares is just a small cherry on top. Please consider the following approach:
Alternatively, we may add some sort of "sandbox" flag to share grants, which is going to permit extra grants on objects not explicitly defined in config. DBT should be able to run post-hook with grants. Probability of interruption will be high, so not good for production usage. But it might be a "good enough" solution for DEV environment. Especially if shares objects are queries manually by humans rather than scripts. |
Beta Was this translation helpful? Give feedback.
-
To be honest, it is really weird Snowflake does not provide future grants for shares. Naturally, it would be the best and the most straightforward solution. |
Beta Was this translation helpful? Give feedback.
-
@kokorin , how about the following implementation? (1) Add test_share:
accounts:
- SFSALESSHARED.SFC_SAMPLES_AWS_EU_WEST_2
grants:
DATABASE:USAGE:
- test_db
SCHEMA:USAGE:
- test_db.test_schema
TABLE:SELECT:
- test_db.test_schema.*
FUNCTION:USAGE:
- test_db.test_schema.test_secure_udf(varchar)
comment: Test share
database_roles:
<database_role_name>:
grants:
DATABASE:USAGE:
- test_db
SCHEMA:USAGE:
- test_db.test_schema
TABLE:SELECT:
- test_db.test_schema.specific_table (2) Internally implement blueprint and resolver for (3) Grant logic will be the same both for shares and for database roles. If you use wildcard pattern (e.g. With this approach we logically attach database roles to outbound shares only. If ever need to implement database roles for anything else in future, we'll come back to this and re-design. But currently I do not see why it might be useful for anything else. No future grants for database roles, only normal grants. No name modifications for database roles, since these roles are public-facing objects. No suffies, no prefixes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In our SF Account we use DBT to create tables we want to share with other SF account through Outbound Share.
These tables are actively developed and column names and types can change from time to time. We created Snowflake's Database Role. This role is granted with privileges on tables we want to share.
Unfortunately, it's not possible to provide Snowflake's Database Role to Outbound Share Blueprint. And because table schemas can change we can't use Outbound Share: SnowDDL suggests re-creating tables if something is changed.
I remember we discussed this topic earlier, but I can't find the thread. To what I remember, the problem was in possible confusion between SnowDDL's DB Role and Snowflake's DB Role.
One of the solutions I can think about is creating programmatic config for Snowflake's Database Roles. This config can include a reference to Outbound Share like this:
If we add Outbound Share configuration (share_1 and share_2) it should be possible to achieve our goal. But such solution would contradict to SnowDDL Outbound Share usage.
Beta Was this translation helpful? Give feedback.
All reactions