terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

Null values in terraform.tfstate file of snowflake_table_constraint while importing data.

Open puneet-nayal opened this issue 1 year ago • 1 comments

Terraform CLI and Provider Versions

Terraform: 1.7.1 Provider: 0.87

Terraform Configuration

resource "snowflake_database" "d" {
  name = "some_db"
}

resource "snowflake_schema" "s" {
  name     = "some_schema"
  database = snowflake_database.d.name
}

resource "snowflake_table" "t" {
  database = snowflake_database.d.name
  schema   = snowflake_schema.s.name
  name     = "some_table"

  column {
    name     = "col1"
    type     = "text"
    nullable = false
  }

  column {
    name     = "col2"
    type     = "text"
    nullable = false
  }

  column {
    name     = "col3"
    type     = "text"
    nullable = false
  }
}

resource "snowflake_table_constraint" "primary_key" {
  name     = "myconstraint"
  type     = "PRIMARY KEY"
  table_id = snowflake_table.t.id
  columns  = ["col1"]
  comment  = "hello world"
}

Expected Behavior

It should generate terrform.tfstate with all its config values { "mode": "managed", "type": "snowflake_table_constraint", "name": "primary_key", "provider": "provider["registry.terraform.io/snowflake-labs/snowflake"]", "instances": [ { "schema_version": 0, "attributes": { "columns": [ "col1" ], "comment": "hello world", "deferrable": true, "enable": true, "enforced": false, "foreign_key_properties": [], "id": "myconstraint❄️PRIMARY KEY❄️some_d12b|some_schema|some_table", "initially": "DEFERRED", "name": "myconstraint", "rely": true, "table_id": "some_d12b|some_schema|some_table", "type": "PRIMARY KEY", "validate": false }, "sensitive_attributes": [], "private": "bnVsbA==", "dependencies": [ "snowflake_database.d", "snowflake_schema.s", "snowflake_table.t" ] } ] }

Actual Behavior

{ "mode": "managed", "type": "snowflake_table_constraint", "name": "primary_key", "provider": "provider["registry.terraform.io/snowflake-labs/snowflake"]", "instances": [ { "schema_version": 0, "attributes": { "columns": null, "comment": null, "deferrable": null, "enable": null, "enforced": null, "foreign_key_properties": [], "id": "myconstraint❄️PRIMARY KEY❄️some_db|some_schema|some_table", "initially": null, "name": null, "rely": null, "table_id": null, "type": null, "validate": null }, "sensitive_attributes": [], "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjAifQ==" } ] }

Steps to Reproduce

  1. terraform apply
  2. terraform import snowflake_table_constraint.primary_key 'myconstraint❄️PRIMARY KEY❄️some_db|some_schema|some_table'

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

puneet-nayal avatar Apr 08 '24 07:04 puneet-nayal

Hey @puneet-nayal. Thanks for reaching out to us.

We will visit the topic of table constraint resource with https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#supporting-all-snowflake-ga-features.

Currently, this resource has not been supporting the read operation: https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/0b947a54a7bd285a4eaa337b6efa69da66d42a17/pkg/resources/table_constraint.go#L346. Changing to feature-request.

sfc-gh-asawicki avatar Apr 08 '24 11:04 sfc-gh-asawicki