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]: grant_privileges_to_share - on_function - An argument named "on_function" is not expected here. #3081

Closed nx-rebecca closed 2 months ago

nx-rebecca commented 2 months ago

Terraform CLI Version

1.8.3

Terraform Provider Version

0.93.0

Terraform Configuration

resource "snowflake_share" "share" {
  provider = snowflake.listing_manager
  name     = "SHARE"
}

resource "snowflake_grant_privileges_to_share" "db_grant" {
  provider    = snowflake.listing_manager
  to_share    = snowflake_share.share.name
  privileges  = ["USAGE"]
  on_database = snowflake_database.db.name
}

resource "snowflake_grant_privileges_to_share" "schema_grant" {
  depends_on = [snowflake_grant_privileges_to_share.db]
  provider   = snowflake.listing_manager
  to_share   = snowflake_share.share.name
  privileges = ["USAGE"]
  on_schema  = "${snowflake_database.db.name}.${snowflake_schema.schema.name}"
}

resource "snowflake_grant_privileges_to_share" "function_grant" {
  depends_on = [snowflake_grant_privileges_to_share.schema]
  provider = snowflake.listing_manager
  to_share = snowflake_share.share.name
  privileges = ["USAGE"]
  on_function = "${snowflake_database.db.name}.${snowflake_schema.schema.name}.${snowflake_function.function.name}(VARCHAR)"
}

Category

category:grants

Object type(s)

resource:grant_privileges_to_share

Expected Behavior

Usage on the function is granted to the share

Actual Behavior

Got this error:

│ Error: Unsupported argument │ │ on ....\modules\pcsect\snowflake-shares.tf line 306, in resource "snowflake_grant_privileges_to_share" "function_grant": │ 306: on_function = "${snowflake_database.db.name}.${snowflake_schema.schema.name}.${snowflake_function.function.name}(VARCHAR)" │ │ An argument named "on_function" is not expected here.

Steps to Reproduce

Run terraform apply (Requires the necessary db, schema and function to exist)

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

According to provider docs (https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_privileges_to_share) on_function is a supported argument.

Would you like to implement a fix?

sfc-gh-jmichalak commented 2 months ago

Hi @nx-rebecca 👋 This feature is supported in v0.95.0. Please migrate to this version, see the migration guide.

Also, objects can be referenced with the fully_qualified_name field, like on_function = snowflake_function.function.fully_qualified_name

nx-rebecca commented 2 months ago

Hi @sfc-gh-jmichalak Thanks for the tip. That seems to have resolved the issue!