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

[General Usage]: snowflake_function gets recreated every time we run terraform plan / apply #3194

Open nx-rebecca opened 1 week ago

nx-rebecca commented 1 week ago

Terraform CLI Version

1.8.3

Terraform Provider Version

0.96.0

Company Name

No response

Terraform Configuration

resource "snowflake_function" "function" {
  depends_on = [snowflake_view.view]
  name       = "FUNCTION"
  database   = snowflake_database.db.name
  schema     = snowflake_schema.schema.name
  is_secure  = "true"
  arguments {
    name = "REQUIREDID"
    type = "VARCHAR"
  }
  comment     = "Function"
  return_type = "TABLE (Issued_at TIMESTAMP_NTZ, ID VARCHAR(16777216), POINT GEOGRAPHY, Validity_date DATE, Max NUMBER(38,2)"
  statement   = <<-EOT
SELECT * FROM "${snowflake_database.db.name}"."${snowflake_schema.schema.name}"."${snowflake_view.view.name}" WHERE "Issued_at" = (SELECT MAX("Issued_at") FROM "${snowflake_database.db.name}"."${snowflake_schema.schema.name}"."${snowflake_view.view.name}") AND ID = REQUIREDID
EOT
}

Category

category:resource

Object type(s)

resource:function

Expected Behavior

We would expect the snowflake_function not to be destroyed/recreated unless it has changed in some way in the tf definition.

Actual Behavior

Every time we run a terraform plan or apply, the snowflake_functions are destroyed and recreated. We think there's probably something not right in our function definition but we're not sure what.

Steps to Reproduce

.

How much impact is this issue causing?

Low

Logs

No response

Additional Information

No response

sfc-gh-asawicki commented 1 week ago

Hey @nx-rebecca. Thanks for reaching out to us.

Function and procedure resources are currently being redesigned so we will tackle this improper behavior with it.

For now, you can use lifecycle#ignore_changes meta-argument to prevent the recreation.