terraform-provider-snowflake
terraform-provider-snowflake copied to clipboard
perpetual diff when adding a share to a snowflake_view_grant
Provider Version
$ terraform version
Terraform v0.14.11
+ provider registry.terraform.io/chanzuckerberg/snowflake v0.25.36
Describe the bug
When you create a snowflake_view_grant resource with a share, you'll get a perpetual diff in your terraform plan's. Terraform will propose adding the grant over and over.
Expected behavior
Terraform should create the desired grant without a perpetual diff.
Code samples and commands
resource "snowflake_database" "a" {
name = "TESTDB"
data_retention_time_in_days = 3
}
resource "snowflake_database_grant" "a" {
for_each = toset([
"USAGE",
"REFERENCE_USAGE",
])
database_name = snowflake_database.a.name
privilege = each.key
roles = []
shares = [snowflake_share.a.name]
with_grant_option = false
}
resource "snowflake_schema" "a" {
database = snowflake_database.a.name
name = "TESTSCHEMA"
comment = "A schema."
is_transient = false
is_managed = false
data_retention_days = 1
}
resource "snowflake_schema_grant" "a" {
database_name = snowflake_database.a.name
schema_name = snowflake_schema.a.name
privilege = "USAGE"
roles = []
shares = [snowflake_share.a.name]
with_grant_option = false
}
resource "snowflake_table" "a" {
database = snowflake_schema.a.database
schema = snowflake_schema.a.name
name = "SOME_TABLE"
comment = "A table."
column {
name = "id"
type = "NUMBER(38,0)"
nullable = true
}
}
resource "snowflake_share" "a" {
name = "JUSTTESTING"
comment = "JUSTTESTING"
}
resource "snowflake_view" "a" {
database = snowflake_database.a.name
schema = snowflake_schema.a.name
name = "JUSTTESTINGSVW"
statement = "select * from ${snowflake_schema.a.name}.SOME_TABLE"
or_replace = true
is_secure = true
}
resource "snowflake_view_grant" "a" {
database_name = snowflake_view.a.database
schema_name = snowflake_view.a.schema
view_name = snowflake_view.a.name
privilege = "select"
roles = []
shares = [snowflake_share.a.name]
with_grant_option = false
depends_on = [
snowflake_share.a,
snowflake_view.a,
]
}
- Apply the above infrastructure.
- Go into the console and do
SHOW GRANTS ON VIEW TESTDB.TESTSCHEMA.JUSTTESTINGSVW;, you'll see that the desired grant to the share exists. - Run
terraform applyand see that Terraform will propose the following change:
~ resource "snowflake_view_grant" "a" {
id = "TESTDB|TESTSCHEMA|JUSTTESTINGSVW|select|false"
~ shares = [
+ "JUSTTESTING",
]
# (7 unchanged attributes hidden)
}
- You can apply the change over and over and the diff never resolves, even though the grant was created as expected.
Any update on this?
We are closing this issue as part of a cleanup described in announcement. If you believe that the issue is still valid in v0.89.0, please open a new ticket.