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

Error: table id is incorrect for snowflake_table_constraint #2535

Closed
freylafert opened this issue Feb 21, 2024 · 8 comments · Fixed by #2513
Closed

Error: table id is incorrect for snowflake_table_constraint #2535

freylafert opened this issue Feb 21, 2024 · 8 comments · Fixed by #2513
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@freylafert
Copy link

Terraform CLI and Provider Versions

terraform --version
Terraform v1.5.5
on darwin_arm64

  • provider registry.terraform.io/hashicorp/aws v5.37.0
  • provider registry.terraform.io/hashicorp/null v3.2.2
  • provider registry.terraform.io/snowflake-labs/snowflake v0.86.0

Terraform Configuration

resource "snowflake_table_constraint" "primary_key" {
  depends_on = [snowflake_table.table]
  provider   = snowflake.account_admin
  for_each   = var.tables
  name       = "${each.value.name}_PRIMARY_KEY"
  type       = "PRIMARY KEY"
  table_id   = snowflake_table.table[each.key].id
  columns    = each.value.primary_key_fields
}

Expected Behavior

apply with no errors

Actual Behavior


│ Error: table id is incorrect: {CNT_DEV|OLEG_CNT_DEV|IP_TO_NAMED_LOCATION}

│ with module.snowflake.snowflake_table_constraint.primary_key["ip_to_named_location"],
│ on ../reporting/snowflake/snowflake.tf line 134, in resource "snowflake_table_constraint" "primary_key":
│ 134: resource "snowflake_table_constraint" "primary_key" {

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

it looks like in version 0.86.0 we need to pass table_id = snowflake_table.t.qualified_name vs table_id = snowflake_table.t.id in the previous versions. While it looks like for existing tables there was no issues to stay with snowflake_table.t.id it fails for new tables apply failes with the error mentioned above. When I change tf configuration to use qualified_name instead of id, I got this error for all existing tables. So it looks like I am stuck now.

@freylafert freylafert added the bug Used to mark issues with provider's incorrect behavior label Feb 21, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @freylafert. Thanks for reaching out to us.

This is apparently an oversight on our side and it should be added to the migration notes.

Identifiers are a never-ending topic. This is why we will soon rework them (https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#our-roadmap). The problem with this resource was that it was using the deprecated identifier parser. Also, the docs were inconsistent because the example showed using the table.id but the description of the table_id parameter never allowed such a value (table.id is a | delimited identifier representation and only the . separated values were listed in the docs: https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.85.0/docs/resources/table_constraint#required - as I can see there is some problem with rendering the proper values here, I will also correct that).

I think that the easiest way to go from here would be to use the existing resource migration guide to remove from state and reimport the affected resources - I will add this to the migration notes.

We will provide a temporary workaround in the next version (next week) so that the manual migration is not necessary, so you can wait for the next version which should solve the problem.

@freylafert
Copy link
Author

Thank you, that makes sense. It will be fixed in the version 0.87.0, right?

@sfc-gh-asawicki
Copy link
Collaborator

In 0.87.0 or 0.88.0. Preferably, in 0.87.0 but I can't promise that.

@rjminchuk
Copy link

#2553 Just opened this.. will close it. Having the same problem. Thanks.

@philippeboyd
Copy link
Contributor

@sfc-gh-asawicki can we also get rid of the emojis in resource IDs? I though we already had this conversation

image

@sfc-gh-asawicki
Copy link
Collaborator

Hey @philippeboyd, you never had a conversation with me.

This is one of the last places with the ❄️-separated identifier. We will get rid of all of them with the upcoming resources redesign: https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#our-roadmap.

Also, please submit new tickets for different problems instead of adding them to the existing unrelated issues.

sfc-gh-asawicki added a commit that referenced this issue Feb 26, 2024
sfc-gh-asawicki added a commit that referenced this issue Feb 27, 2024
…2558)

- Fix the migration guide
- Fix the docs
- Fallback to `|`-delimited id for users' convenience

References: #2535
sfc-gh-jcieslak pushed a commit that referenced this issue Feb 28, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.87.0](v0.86.0...v0.87.0)
(2024-02-28)


### 🎉 **What's new:**

* Add network rule to the sdk
([#2526](#2526))
([b379565](b379565))
* supports collation of table column
([#2496](#2496))
([56771f1](56771f1))


### 🔧 **Misc**

* Clean up environment variables in tests and on CI
([#2543](#2543))
([9a10cb1](9a10cb1))
* replace warning in new grant resources with info log
([#2521](#2521))
([c3014b9](c3014b9))


### 🐛 **Bug fixes:**

* data retention days follow up
([#2566](#2566))
([7aba384](7aba384))
* data retention time parameters
([#2502](#2502))
([76abf21](76abf21))
* data retention time parameters follow-up
([#2530](#2530))
([5544544](5544544))
* Demote warning to info and set volatility for procedures and functions
([#2567](#2567))
([abaad7c](abaad7c)),
closes
[#2536](#2536)
* Fix ACCOUNT PARAMETERS option failover group resource
([#2522](#2522))
([61883f3](61883f3)),
closes
[#2517](#2517)
* Fix failover group alter syntax and suppression for pipe statement
([#2562](#2562))
([24d76c3](24d76c3))
* Fix few tests
([#2515](#2515))
([a523a6b](a523a6b))
* Fix provider config hierarchy
([#2551](#2551))
([677a12b](677a12b))
* Fix query_results in unsafe_execute resource
([#2512](#2512))
([94ca158](94ca158)),
closes
[#2491](#2491)
* Fix replication for database resource
([#2524](#2524))
([767fbce](767fbce)),
closes
[#2021](#2021)
* Fix show by id for external functions
([#2531](#2531))
([d910a84](d910a84)),
closes
[#2528](#2528)
* Fix various small problems
([#2552](#2552))
([f558ce6](f558ce6))
* Granting database roles
([#2511](#2511))
([dc27d64](dc27d64)),
closes
[#2402](#2402)
* grants on external volumes
([#2538](#2538))
([1de9a29](1de9a29))
* Handle old reference for table_id in table constraint resource
([#2558](#2558))
([d1e8912](d1e8912)),
closes
[#2535](#2535)
* loosen identifier field validation for account object identifiers
([#2564](#2564))
([a5ed8cd](a5ed8cd))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: snowflake-release-please[bot] <105954990+snowflake-release-please[bot]@users.noreply.github.com>
@sfc-gh-asawicki
Copy link
Collaborator

Hey @freylafert. We have released the fix as part of v0.87.0 release. Please follow the migration guide during the update. Please confirm that the issue is resolved in the newest version. Thanks!

@freylafert
Copy link
Author

Thanks you, the issue is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants