[❄️ Snowflake Official ] Grant Issues Update #1890
Replies: 24 comments 44 replies
-
Has anyone on the Snowflake Terraform Provider team created a state importer tool for the provider. That would certainly help ease this migration. If not, I'll get working on one. |
Beta Was this translation helpful? Give feedback.
-
I understand that the recommendation is to migrate to the new grant resources at our earliest convenience. Are the new grant resources ready for use? |
Beta Was this translation helpful? Give feedback.
-
When will this be released? Prior to the release, could you please publish the import syntax so we can prepare? |
Beta Was this translation helpful? Give feedback.
-
It seems like the current outstanding issue with grants is the enable multiple grants bug that was introduced recently. Can you help me understand why that change can't be reverted? It would allow us to continue our work without breaking all existing grants and avoid rewriting all our code immediately. And then the Snowflake team can work on the new resources that we can migrate to when we're ready |
Beta Was this translation helpful? Give feedback.
-
This is vastly improved because the ID of the grant resource is the principal getting the grant. |
Beta Was this translation helpful? Give feedback.
-
I think it is also worth pointing out that the opt out period for bundle 2023_03, which broke provider versions <= 0.64, is scheduled to end 2023-07-10. Disabling the bundle and staying on versions <= 0.64 right now is by far the easiest way to avoid the very recently created issue introduced by the change to enable_multiple_grants. Once the opt out period ends, we need to have a solution ready that allows us to upgrade to a version > 0.64. Forcing us to migrate to a currently unreleased API before 2023-07-10 seems like an unrealistic window to pull this off safely. |
Beta Was this translation helpful? Give feedback.
-
If this is the plan, you should stop working on 0.X and focus on 1.0 because most of us can't upgrade past 0.64 and thus are unable to use any new release due to this issue. |
Beta Was this translation helpful? Give feedback.
-
Ready to test a first version. |
Beta Was this translation helpful? Give feedback.
-
The grant resource is now available in 0.68 release: https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_privileges_to_role |
Beta Was this translation helpful? Give feedback.
-
These resources are so much more intuitive, thank you so much team! |
Beta Was this translation helpful? Give feedback.
-
For anyone in the same situation, here's the issue #1952 and the PR #1967 aims to solve it. Does anyone have an idea on how to migrate from resource "snowflake_external_table_grant" "select" {
database_name = var.db_name
privilege = "SELECT"
roles = [
"ROLE_1",
"ROLE_2",
]
on_future = true
with_grant_option = false
provider = snowflake.securityadmin
} I don't see any mention of the word "external" in the docs for snowflake_grant_privilege_to_role. I tried doing it with this resource "snowflake_grant_privileges_to_role" "future_external_tables" {
privileges = ["SELECT", "REFERENCES"]
role_name = "ROLE_1"
on_schema_object {
future {
object_type_plural = "TABLES"
in_database = var.db_name
}
}
} which does show the |
Beta Was this translation helpful? Give feedback.
-
With the old resource Without this attribute if I use these new resources to grant the ownership of a schema to a specific role it works fine during the apply phase, but when I try to destroy it fails because I cannot destroy the Can someone explain it this behavior is expected or not? And, if not, will it be fixed? |
Beta Was this translation helpful? Give feedback.
-
Hi, I have tried to use the new resources, may be this might be an existing issue. but later if there are more tables created and to provide access to those tables there is no way apart from deleting the role and re creating And I was in assumption that all{} grants access to all objects for already created and future grants but is not the case, in that case can we have that explicitly mentioned in the documentation as both all and future cannot be used in single resource it would be great if we can atleast use both all {} future {} blocks in a single resources which will save some time for already created schemas/tables or which are not tracked via terraform. |
Beta Was this translation helpful? Give feedback.
-
If anyone has found an easy way to create a kind of read-role for a schema/database/account( select on all object types) it would be great to post here |
Beta Was this translation helpful? Give feedback.
-
Thanks to the whole team for all the improvements. grant_privilege_to_role is a great resource that covers most of my use cases. Do you plan to add a flag/parameter to can mimic "REVOKE CURRENT GRANTS" feature? |
Beta Was this translation helpful? Give feedback.
-
is there any timeline on |
Beta Was this translation helpful? Give feedback.
-
Hey, great work there! I have a question: how grants to share will be handled? In the current |
Beta Was this translation helpful? Give feedback.
-
Hey, folks! Getting back to this, is there a way to have database imported privileges controlled by the new resources? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the ongoing improvements, consolidating grants makes a lot of sense! Just a simple suggestion: would it be possible to provide the schema's fully qualified name as an attribute of Using your example above, it is straightforward to refer to a database name by using its resource "snowflake_grant_privileges_to_role" "g1" {
privileges = ["MONITOR", "CREATE SCHEMA"]
role_name = snowflake_role.r.name
on_account_object {
object_type = "DATABASE"
object_name = snowflake_database.d.name
}
} However, referring to a schema requires its fully qualified name which is not directly available as an attribute of resource "snowflake_grant_privileges_to_role" "g2" {
depends_on = [ snowflake_schema.s , snowflake_table.t]
role_name = snowflake_role.r.name
privileges = ["SELECT", "INSERT"]
on_schema_object {
all {
object_type_plural = "TABLES"
# When referring a `snowflake_schema` resource, the syntax becomes rather ugly:
in_schema = "\"${snowflake_schema.s.database}\".\"${snowflake_schema.s.name}\""
}
}
} If the fully qualified name was available as an attribute, the syntax would be much simpler: resource "snowflake_grant_privileges_to_role" "g2" {
depends_on = [ snowflake_schema.s , snowflake_table.t]
role_name = snowflake_role.r.name
privileges = ["SELECT", "INSERT"]
on_schema_object {
all {
object_type_plural = "TABLES"
in_schema = snowflake_schema.s.fqn
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Will snowflake_grant_account_role be deprecated as well? I noticed that there isn't an option/example of using snowflake_grant_privileges_to_account_role to grant role privileges to another role. What is the recommended approach for role to role access mapping via terraform? |
Beta Was this translation helpful? Give feedback.
-
While I generally agree with cleaning up the approach to grants, I think the new terraform resources make it basically impossible to handle an important use-case for us. For background, my team uses terraform to manage all our Snowflake infrastructure across several Snowflake accounts, and we just went through the process of upgrading to the The use case these new resources appear to miss is the ability to assert that a certain privilege is granted to a set of grantees and only those grantees. For example, if we grant With this property, auditing our Snowflake accounts to ensure that they have only the intended grants which have been reviewed and approved in the terraform code is as simple as running Without this property, the terraform becomes basically useless in performing such an audit of grants. Managing audits for things like SOX and SOC2 etc. are unfortunately burdensome enough as it is; I'd hate to see the Snowflake terraform provider evolve in a way which makes them even harder. Unintentional grants do crop up over time, including through someone manually granting privileges outside of the terraform, or just in the course of performing refactoring to the terraform and moving around state as a result. We can't always rely on terraform state knowing that there was once a grant which now needs to be removed. This is related to the messy history of the Were the maintainers of this provider unaware of the desirability of this property? Or have you considered it at length and chosen not to address it? Is it considered too late to modify the new resources to enable this behavior? Or could we address this use case by introducing more resource variants like |
Beta Was this translation helpful? Give feedback.
-
Hey, with the latest release (v0.88.0), we concluded the redesign of grants. Thank you all for your patience! Grants have received much of our attention in the past few months, and they're in a much better state now. We will move now to other essential topics before the V1. You can check the summary of introduced changes and future challenges in grants_redesign_design_decisions.md. Thank you all for the feedback and issue reports; they helped us steer the grants in the right direction. Now that all the new grants are available, we would love to hear your thoughts on using them in practice, so please share any usability concerns or missing parts. |
Beta Was this translation helpful? Give feedback.
-
Hi team, thanks for all your great work on this. I have a number of questions before my org plans the work to complete the migration:
Please let me know if there is a better place to post these questions. cc @sfc-gh-asawicki @sfc-gh-jcieslak @sfc-gh-swinkler @sfc-gh-bculberson @sfc-gh-ckite |
Beta Was this translation helpful? Give feedback.
-
My team is moving to these new grant resources, but I cannot for the life of me figure out how grants for procedures and functions with input arguments should work. The deprecated resource: snowflake_procedure_grant has the attribute argument_data_types that allows you to define the datatypes of the inputs as an array. Is there anything similar in the new resources? |
Beta Was this translation helpful? Give feedback.
-
We, the Snowflake Terraform Provider team, are aware of the many grant resource issues which negatively impact users. Grant resources are a critical piece of infrastructure required by everyone, and even small issues can become major blockers. This is extremely frustrating, and we apologize for any inconvenience you have experienced when using these resources.
The existing 26 grant resources (which comprise about 1/3 of all resource types) are difficult to maintain and there are insufficient tests. Even small changes, seemingly innocuous, have lead to breaking changes for users. The evidence suggests that we cannot safely apply changes to or maintain these current grant resources.
We present here our solution. As originally outlined in Grant Resource Refactoring Discussion we plan to deprecate all 26 of the existing grant resources and replace them with three new resources:
grant_privileges_to_role
,grant_privileges_to_database_role
, andgrant_ownership_to_role
.These resources more closely match the API, and have been written into our new SDK framework. This means it is well tested (unit + integration tests) and is thus a lot easier to maintain. The existing grant resources will be removed from the provider in a later 1.0 release. We do not plan to further patch or maintain these old grant resources going forward given the high risk.
We understand that this will mean considerable rewrite for many users. If it was not so urgent to fix grants, and relieve the stress users have been experiencing over this problematic resource, we would wait until version 2.0 to release this kind of change. We thank you in advance for your patience and understanding.
##Examples
Note: the complete schema will be available in the documentation when this resource is available.
Global Privileges
Account Object Privileges
Schema Privileges
Schema Object Privileges
Q: What does this mean for me?
A: We highly recommend migrating to the new grant resources at your earliest convenience. The easiest thing to do will be to destroy all your existing grants and re-create them. Since this may not be possible for all users, it’s also possible to import the grants.
Q: Can you patch one particular issue for me?
A: We have seen repeated issues while attempting to patch the existing grant resources. Unintended side effects have been myriad. The lack of tests means we cannot reliably screen for those side effects. Given the risk this imposes to customers, we cannot continue patching that code.
Beta Was this translation helpful? Give feedback.
All reactions