Snowflake-Labs / terraform-provider-snowflake

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

[Bug]: grant_ownership does not work on procedure #2784

Open YAhiru opened 2 months ago

YAhiru commented 2 months ago

Terraform CLI Version

1.8.3

Terraform Provider Version

0.89.0

Terraform Configuration

resource "snowflake_database" "test" {
  name = "DB"
}

resource "snowflake_schema" "test" {
  name     = "SCHEMA"
  database = snowflake_database.test.name
}

resource "snowflake_role" "test" {
  name = "TEST"
}

resource "snowflake_grant_account_role" "test" {
  role_name = snowflake_role.test.name
  parent_role_name = "SYSADMIN"
}

resource "snowflake_procedure" "test" {
  name        = "PROCEDURE"
  database    = snowflake_database.test.name
  schema      = snowflake_schema.test.name
  language    = "JAVASCRIPT"
  return_type = "VARCHAR"
  statement   = "return 'Hi'"
}

resource "snowflake_grant_ownership" "test" {
  account_role_name   = snowflake_role.test.name
  on {
    object_type = "PROCEDURE"
    object_name = "${snowflake_database.test.name}.${snowflake_schema.test.name}.${snowflake_procedure.test.name}()"
  }
}

Category

category:identifiers

Object type(s)

resource:grant_ownership

Expected Behavior

expected fully qualified name is "DB"."SCHEMA"."PROCEDURE"()

Actual Behavior

but actual is "DB"."SCHEMA"."PROCEDURE()"

│ Id: ToAccountRole|"TEST"||OnObject|PROCEDURE|"DB"."SCHEMA"."PROCEDURE()"
│ Error: 090208 (42601): Argument types of function 'PROCEDURE()' must be specified.

Steps to Reproduce

  1. copy the following configuration
  2. terraform apply

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

The workaround for grant_privileges_to_account_role does not work because of the different parse logic of IDs.

Even if parse logic is the same, it does not work in a empty arguments because the () is removed. The following error should occur

Error: 090208 (42601): Argument types of function 'SOME_PROCEDURE' must be specified.

Would you like to implement a fix?

YAhiru commented 2 months ago

If I can figure out the details of identifiers rework, I can create a PR :)

sfc-gh-jcieslak commented 2 months ago

Hey 👋 Thanks for creating an issue for this. The identifiers rework will happen this quarter, but we haven't started it yet. We have to analyze all the cases where we feel the identifiers are lacking and provide a proposal we can all agree on. Without the proposal, we cannot give any instructions, but I will link this issue to do it as part of the identifiers rework.