How can users manage Snowflake Tasks /w Terraform w/ different owner roles? #2877
Replies: 3 comments
-
Hey @liamjamesfoley. In the Snowflake docs, there is a good extract on changing the ownership of DAGs: https://docs.snowflake.com/en/user-guide/tasks-graphs#manage-task-graph-ownership. Please check it out. I have pushed an automatic test showing a small working sample for a similar setup and the second solution from https://docs.snowflake.com/en/user-guide/tasks-graphs#manage-task-graph-ownership.In the first step In the second step Then, the third step is the first step to try to follow the second solution in https://docs.snowflake.com/en/user-guide/tasks-graphs#manage-task-graph-ownership, so transferring the ownership to all the tasks inside a schema by first revoking the ownership back to the terraform user role: The fourth step succeeds with a config: This is one of the possible ways. The two more I could think of (but did not verify them in practice) are:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply @sfc-gh-asawicki, I've considered the extra provider solution, but would like to not have N number of providers, where N is the number of roles that could own tasks. As for the demo you provided, it seems like the usage of f5c9954#diff-205fe850fe5a9779651b1b4cdb2dd1d86106b427f0854f9072e52d8e5b7bb8dbR23 Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Hey. You have linked the second step, which shows the same error behavior that you encountered. The right steps to accomplish the desired state are 3 and 4. The use of depends_on is not necessary to show the error, though, but allows us to tell terraform in what order the resources should be created (but again, it does not matter in this case). Users can follow steps 1 -> 3 -> 4 to accomplish the result you want. Also, this follows the https://docs.snowflake.com/en/user-guide/tasks-graphs#manage-task-graph-ownership, so it's not provider-specific. |
Beta Was this translation helpful? Give feedback.
-
👋
Hello!
I'm having trouble with manage tasks in Terraform b/c of the Task ownership model.
in order to follow the principle of least privilege, we want tasks to execute as (and therefore be owned by) different roles.
How can we accomplish this given the current tasks API?
Since its impossible to create a task owned by a role other than the current role, upon creation, all our task are owned by
TERRAFORM_ROLE
(set up in our provider).We can transfer the ownership using
snowflake_grant_ownership
But when we try to add downstream dependent tasks, the TF apply fails:
Basically it's impossible to run:
CREATE TASK_A;
GRANT OWNERSHIP ON TASK_A TO ROLE MY_ROLE;
CREATE TASK B AFTER TASK_A; -- This fails
GRANT OWNERSHIP ON TASK_B TO ROLE MY_ROLE;
Full Example (TASK_B was added in a subsequent PR):
Module:
Module definition:
Module variables:
Beta Was this translation helpful? Give feedback.
All reactions