Replies: 1 comment 3 replies
-
In my opinion, cloning is a big trap in general. It seems like a good idea at first, but it creates a lot of various sneaky problems which are difficult to solve. But let's see what we can do here.. Depending on the end goal, we may consider two possible solutions: (1) If clones are an integral part of production environment and used for business logic When the time comes, you only "clone" individual objects from Do not clone entire databases or schemas, it creates too many issues with ownership, grants, sequences, etc. (2) If clones are a part of separate environment in any shape or form, or should be managed by other tools After that you may clone objects from More importanly, SnowDDL will not try to manage any objects which are not explicitly owned by role other than SnowDDL admin role. Your objects will be safe from intervention. |
Beta Was this translation helpful? Give feedback.
-
I have a database
RAW
which is fully managed by SnowDDL, thus I have a schema tech role for every schema in this db. I also create a clone of this database,RAW_SNAPSHOT
, once daily, using templated SQL executed by an orchestration tool. Clones may occur at the db level, schema level, or table level, depending on configuration of this workflow. When the clone occurs at thedatabase
orschema
level, I also copy all grants from the source to target (this is necessary because by default Snowflake doesn't copy grants from the container objects, only children objects - see https://docs.snowflake.com/en/user-guide/object-clone#access-control-privileges-for-cloned-objects). This code works and is reliableI was hoping to let the orchestrator tool fully own and manage this cloned snapshot db, but now I've discovered that this workflow is creating resource drift with the grants for schema tech roles in the source db. For example, suppose I have a schema
RAW.MYSCHEMA
and associated schema tech roleRAW__MYSCHEMA__OWNER_S_ROLE
that hasUSAGE ON DATABASE RAW
grant. When I clone the schema toRAW_SNAPSHOT
, I also clone the grants - soRAW__MYSCHEMA__OWNER_S_ROLE
now hasUSAGE ON DATABASE RAW_SNAPSHOT
grant. Then the next time I runsnowddl plan
, the tool notices all these additional grants and tries to revoke them from the schema role -REVOKE USAGE ON DATABASE "RAW_SNAPSHOT" FROM ROLE "RAW__MYSCHEMA__OWNER__S_ROLE";
Is there any way to tell SnowDDL "ignore additional grants on schema tech roles which were not granted by
SNOWDDL_ADMIN
"? Or is my approach of letting the orchestrator handle this clone and it's grants generally not going to work? I know SnowDDL has a--clone-table
CLI flag, but this doesn't really seem like the appropriate use case, because I am not separating environments here, but just performing one more step in an ETL pipeline. Furthermore the code being run by my orchestrator tool is reliable and very performant because it clones the objects async, which is necessary because there are a large number of objects to clone and we have a strict SLA on the clone time. So I would prefer to let the orchestrator fully manage this clone, and just let the privileges granted on the source objects by SnowDDL just "propagate" over into the cloneBeta Was this translation helpful? Give feedback.
All reactions