Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
puneet-nayal opened this issue Apr 8, 2024 · 1 comment
Labels
category:resource feature-request Used to mark issues with provider's missing functionalities resource:table_constraint Issue connected to the snowflake_table_constraint resource

Comments

@puneet-nayal
Copy link

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 puneet-nayal added the bug Used to mark issues with provider's incorrect behavior label Apr 8, 2024
@sfc-gh-asawicki sfc-gh-asawicki added feature-request Used to mark issues with provider's missing functionalities and removed bug Used to mark issues with provider's incorrect behavior labels Apr 8, 2024
@sfc-gh-asawicki
Copy link
Collaborator

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:

// commenting this out since it requires an active warehouse to be set which may not be intuitive.
. Changing to feature-request.

sfc-gh-jcieslak added a commit that referenced this issue Apr 18, 2024
This change fixes all of the Updates that were performing re-names to
always setId at the end of the rename operation as well as updating id
that was used in the later operations. Also, the `ForceNew`s were
removed in cases where rename was also handled in the Update. Test cases
were added to show that rename is going through Update and not
DeleteAndCreate operation + additional param is always changed to see if
other operations are affected by the previous rename operation. The
table constraint was adjusted and cannot support the rename for now
(until the Read operation is working #2683). Migration guide updated for
behavioral changes.

---------

Co-authored-by: Artur Sawicki <[email protected]>
@sfc-gh-jcieslak sfc-gh-jcieslak added resource:table_constraint Issue connected to the snowflake_table_constraint resource category:resource labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:resource feature-request Used to mark issues with provider's missing functionalities resource:table_constraint Issue connected to the snowflake_table_constraint resource
Projects
None yet
Development

No branches or pull requests

3 participants