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

Provider demands tag optional property to be defined as [""] #1394

Closed
dlouseiro opened this issue Dec 5, 2022 · 8 comments
Closed

Provider demands tag optional property to be defined as [""] #1394

dlouseiro opened this issue Dec 5, 2022 · 8 comments
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:tag Issue connected to the snowflake_tag resource

Comments

@dlouseiro
Copy link

Provider Version

0.51.0

Terraform Version

v1.3.6

Describe the bug

When a snowflake_tag resource is created without allowed_values, the provider detects changes upon every terraform plan/apply, assuming that we're trying to change the value of allowed_values from [""] to null.

After some deeper investigation, I noticed that what is materialized in the terraform state when allowed_values is omitted is something like this:

"allowed_values": [
              ""
            ]

Although, when I run a SHOW TAGS, the allowed values are actually materialized as NULL when the allowed_values property is omitted, so if I run terraform apply multiple times, terraform always considers that the value for allowed_values is being changes from null to [""].

In order to ensure state consistency, I needed to force allowed_values = [""] in my terraform configuration.

Expected behavior

I'd expect the omission of an optional property to produce consistent states between what is in the state file and what is materialized in the database.

@dlouseiro dlouseiro added the bug Used to mark issues with provider's incorrect behavior label Dec 5, 2022
@bogdan-cioata
Copy link

bogdan-cioata commented Dec 6, 2022

Same here with 0.52, thanks reporting it!
allowed_values seems to be brought here: https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/1006/files#diff-38d5b48223911a8815b351930063d559dc5d182c2cef11bb9c262064f7787d3d

Also, seems that the resource attributes are weirdly ordered, not that it makes a difference:

+ resource "snowflake_tag" "xxx" {
      + allowed_values = [
          + "",
        ]
      + comment        = "comment"
      + database       = "database_name"
      + id             = (known after apply)
      + name           = "tag_tame"
      + schema         = "PUBLIC"
    }

vs.:

+ resource "snowflake_tag_association" "xxx" {
      + id              = (known after apply)
      + object_type     = "DATABASE"
      + skip_validation = true
      + tag_id          = (known after apply)
      + tag_value       = "tag_value"

      + object_identifier {
          + name = "database_name"
        }
    } 

@bogdan-cioata
Copy link

As a workaround, until the bug is fixed, you can use instead:

lifecycle {
    ignore_changes = [
      allowed_values
    ]
  }

@dlouseiro
Copy link
Author

dlouseiro commented Dec 14, 2022

As a workaround, until the bug is fixed, you can use instead:

lifecycle {
ignore_changes = [
allowed_values
]
}

@bogdan-cioata

Won't this also ignore changes in allowed_values when there are "actual" changes, as in, when we actually change the allowed values of this tag?

@bogdan-cioata
Copy link

the workaround is for when you don't fill allowed_values.

@dlouseiro
Copy link
Author

I just upgraded the provider to version 0.61 and it seems that this problem is now fixed.

@sfc-gh-asawicki
Copy link
Collaborator

Hey @dlouseiro, can we close the issue then?

@sfc-gh-jcieslak sfc-gh-jcieslak added category:resource resource:tag Issue connected to the snowflake_tag resource labels May 20, 2024
sfc-gh-jmichalak added a commit that referenced this issue Nov 20, 2024
<!-- Feel free to delete comments as you fill this in -->
- rework tag resource for v1
- generate asserts and models
- deprecate snowflake_tag_masking_policy_association
- extract a parser for extracting schema object identifier list
<!-- summary of changes -->

## Test Plan
<!-- detail ways in which this PR has been tested or needs to be tested
-->
* [x] acceptance tests
<!-- add more below if you think they are relevant -->
* [ ] …

## References
<!-- issues documentation links, etc  -->
https://docs.snowflake.com/en/sql-reference/sql/create-tag

#1806

#1443

#1394

## TODO
- tag data source
- tag association resource
- asserting that ALTER MASKING POLICY [ IF EXISTS ] <name> SET TAG
doesn't alter the tag and vice-versa
- we already unset masking policies from the tags on the tag part, but
we're missing this on masking policies part - add acc tests, too
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @dlouseiro @bogdan-cioata 👋

This was already fixed in v0.61, but we've just released v0.99.0 (release, migration guide) in which we reworked tags. Please upgrade to this version and let us know if you have any issues.

@sfc-gh-jmichalak sfc-gh-jmichalak self-assigned this Dec 17, 2024
@sfc-gh-dszmolka
Copy link
Collaborator

closing based on the comments. let us know please if you still see any issues with the latest provider (v1)

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 category:resource resource:tag Issue connected to the snowflake_tag resource
Projects
None yet
Development

No branches or pull requests

6 participants