Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
552 stars 420 forks source link

[Bug]: snowflake_grant_privileges_to_share results in permadiff when granting to external tables #3167

Open maxnsdia opened 3 weeks ago

maxnsdia commented 3 weeks ago

Terraform CLI Version

1.9.8

Terraform Provider Version

0.97

Terraform Configuration

Using the resource snowflake_grant_privileges_to_share results in a permadiff when granting for external tables. https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/ Would we need the parameter "on_external_table"? I'm using "on_table" now for external tables, but it seems when refreshing the state, it results in a permadiff, it wants to add the grants again. The apply does succeed and I can see the grant is given.

resource "snowflake_grant_privileges_to_share" "table" {
  to_share     = "myshare"
  privileges   = ["SELECT"]
  on_table     = "db.schema.externaltablename"
}

Category

category:grants

Object type(s)

resource:grant_privileges_to_share

Expected Behavior

I expect new grants for external tables on a share to be planned and applied once.

Actual Behavior

The grants keep being planned, resulting in a permadiff.

Steps to Reproduce

How much impact is this issue causing?

Low

Logs

No response

Additional Information

No response

Would you like to implement a fix?

sfc-gh-jcieslak commented 3 weeks ago

Hey @maxnsdia 👋 I'm guessing that in this case there may be an object type mismatch in SHOW GRANTS, probably "EXTERNAL TABLE" is returned when we expect "TABLE". Other table types are something new and they have to be added for this resource to work with them. Marking this as a future request. For now, the only workaround is to use unsafe_execute until fields for other types will be there.