[❄️ Snowflake Official] Grant Resource Refactoring #1470
Replies: 6 comments 1 reply
-
I think the 10 resource approach makes sense as it alleviates the complexity of trying to do it all within only 5. The only thing I would ask is that the current approach still work in a deprecated fashion. For example, the AWS Terraform provider deprecated a bunch of parameters for their s3_bucket resource. Might be trickier to accomplish the same with resources rather than parameters for a resource, but would be ideal if possible. |
Beta Was this translation helpful? Give feedback.
-
This is not a comment on the number of resources, but I see a lot of promise in this suggested approach. My spontaneous thought is that turning the current "many-roles-to-one-privilege"-mapping to "one-role-to-many-privileges" is already a welcome change, and will reduce a lot of complexity (and risks of collateral damage! I'm referring to issue #1200) that are associated with managing grants. 👍 |
Beta Was this translation helpful? Give feedback.
-
Would five resources but adding the ability to specify the type (account, schema, etc.) of grant make sense? |
Beta Was this translation helpful? Give feedback.
-
One thing I would ask is that there is a resource to grant N roles TO Another role. Right now I believe that role granting works by specifying a role and then specifying what roles have access to it, whereas a common pattern is to grant a number of roles to a single "roll-up role". I appreciate that we are talking about moving to a system where multiple privileges (or |
Beta Was this translation helpful? Give feedback.
-
Idea:
In a large org, the current |
Beta Was this translation helpful? Give feedback.
-
Closing as the grant redesign was concluded. More info here. |
Beta Was this translation helpful? Give feedback.
-
Introduction
Hello, I am Scott Winkler! I am a Snowflake employee and tech lead in charge of maintaining the provider. I would like to use this discussion forum as an avenue to gather public opinion and share internal roadmap planning. We would like to do a better job of engaging with the community. If you find this kind of topic to be useful, then please leave a 👍 and comment below.
Problem Statement
There are currently 25 grant resources, which can be confusing to use because its not always clear what APIs are being invoked under the hood. I propose refactoring grant resources to better match what the grant API supports https://docs.snowflake.com/en/sql-reference/sql/grant-privilege.html.
There are basically five different kinds of grants:
The question is: how many resources should be created to manage these different grants? 5? 10? Or something else?
5 Resources
Because there are five basic types of grants, the simplest approach would be to create five different types of resources:
snowflake_role_grant
snowflake_database_role_grant
snowflake_share_grant
snowflake_role_ownership_grant
snowflake_database_role_ownership_grant
These five resources would replace all existing 25 grant resources that we have. An example implementation of the
snowflake_role_grant
is shown belowAlternatively, we could have code blocks to group each type of privilege together:
These implementations both closely matches the API. However, one thing I am worried about is that the
snowflake_role_grant
andsnowflake_database_role_grant
would be difficult to use, because they have so many attributes. In December I faced a similar problem when I was creating some new resources to manage Snowflake parameters. It would have been possible to create a single overarchingsnowflake_parameter
resource to handle everything, but i thought that it would make more sense from a usability point of view to have them as three separate resources which you can see here:I believe this was a good decision, but I also didn't solicit feedback from the community, something I hope to remedy this time around. That brings me to the second proposal that I have.
10 Resources
Since the role grants and database role grants are fairly complex, it might make sense to split them into separate resources based on the type of privileges you are trying to assign. For example we could have the following 10 resources.
snowflake_role_grant_global_privileges
snowflake_role_grant_account_object_privileges
snowflake_role_grant_schema_privileges
snowflake_role_grant_schema_object_privileges
snowflake_database_role_grant_privileges
snowflake_database_role_grant_schema_privilges
snowflake_database_role_grant_schema_object_privileges
snowflake_share_grant_object_privileges
snowflake_role_ownership_grant
snowflake_database_role_ownership_grant
Note that role_grant has been split into 4 different resources, and database role grant has been split into 3. An example of the
snowflake_role_grant_global_privileges
resource is shown below.As you can see, its quite a bit simpler, and more focused on global privileges in particular.Similarly for the
snowflake_role_grant_schema_object_priviliges
as shown below. This one is more complicated, but at least the complexity is contained and doesn't spill over into other types of role grants.The question I have for the community is what do you thing the best course of action is? Do you see the existing grant resources as being a problem, or not really? If you were to refactor grant resources, how would you do it?
Also I am not sure on the names of what these resources should be yet. I figured it should be done in a way that groups them together when you are searching, but open to suggestions.
16 votes ·
Beta Was this translation helpful? Give feedback.
All reactions