-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: grants on future tables in database not working #3142
Comments
I have found this article helpful but I am having an issue with the code:
}
|
Here's an example of what I believe you are trying to achieve. Please let me know if that helps: resource "snowflake_account_role" "test" {
name = "test_tf_role"
}
resource "snowflake_grant_account_role" "test" {
role_name = snowflake_account_role.test.name
user_name = "<your_username>"
}
resource "snowflake_database" "test" {
name = "test_tf_db"
}
resource "snowflake_schema" "test" {
database = snowflake_database.test.name
name = "test_tf_sch"
}
resource "snowflake_grant_privileges_to_account_role" "database_usage" {
privileges = ["USAGE"]
account_role_name = snowflake_account_role.test.name
on_account_object {
object_type = "DATABASE"
object_name = snowflake_database.test.name
}
}
resource "snowflake_grant_privileges_to_account_role" "schema_usage" {
privileges = ["USAGE"]
account_role_name = snowflake_account_role.test.name
on_schema {
schema_name = snowflake_schema.test.fully_qualified_name
}
}
resource "snowflake_grant_privileges_to_account_role" "test" {
privileges = ["SELECT", "INSERT"]
account_role_name = snowflake_account_role.test.name
on_schema_object {
future {
object_type_plural = "TABLES"
in_database = snowflake_database.test.name
}
}
}
resource "snowflake_table" "test" {
database = snowflake_database.test.name
schema = snowflake_schema.test.name
name = "test_tf_table"
column {
type = "NUMBER(38,0)"
name = "num"
}
} You have to replace use role accountadmin;
grant usage on warehouse snowflake to role "test_tf_role"; -- should be granted by higher privileged role like ACCOUNTADMIN, needed for insert
use role "test_tf_role";
use warehouse snowflake;
insert into "test_tf_db"."test_tf_sch"."test_tf_table" values (1), (2), (3);
select * from "test_tf_db"."test_tf_sch"."test_tf_table"; which proves that the future grants were granted. |
I found out that future grants on objects in a schema given to mkre specialist roles will actually dominate over grants applied on schema level to more general roles. A quirck of Snowflake. The solution was to use for each to apply the individual grants to the general roles |
Ok, then it seems like we are good to close the thread, right? |
Terraform CLI Version
1.8.1
Terraform Provider Version
0.97.0
Terraform Configuration
Category
category:resource
Object type(s)
resource:grant_privileges_to_account_role
Expected Behavior
I expect to be able to access future tables
Actual Behavior
Role can't access new objects created in database
Steps to Reproduce
followed by terraform apply
How much impact is this issue causing?
High
Logs
No response
Additional Information
No response
Would you like to implement a fix?
The text was updated successfully, but these errors were encountered: