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

[Bug]: "snowflake_tag_association" failing if table was recreated without a tag outside of Terraform #2943

Closed
1 task
dbieliaiev opened this issue Jul 17, 2024 · 3 comments
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior resource:tag_association Issue connected to the snowflake_tag_association resource

Comments

@dbieliaiev
Copy link

Terraform CLI Version

1.9.2

Terraform Provider Version

0.93.0

Terraform Configuration

resource "snowflake_tag" "privacy_tag" {   
  database = "DB" 
  name = "PRIVACY_TAG" 
  schema = "TAG_LIBRARY" 
  allowed_values = ["NO_CLASSIFICATION","OBJECT_ID","PERSONAL_DATA","PII"] 
  comment = "high level column level tagging to categorise sensitive data for Snowflake data classification"
}

resource "snowflake_tag_association" "tag_pii_columns_prod_db" {
  object_identifier {
    name     = "EXAMPLE_TABLE.COLUMN"
    database = "DB"
    schema   = "EXAMPLE_SCHEMA"
  }
  object_type = "COLUMN"
  tag_id      = snowflake_tag.privacy_tag.id
  tag_value   = "PERSONAL_DATA"
}

Category

category:resource

Object type(s)

resource:tag_association

Expected Behavior

Provider identifies that tag was removed from column, plans to add it.

Actual Behavior

Error: sql: Scan error on column index 0, name "TAG": converting NULL to string is unsupported

Steps to Reproduce

  1. Create a snowflake_tag_association resource to tag a column
  2. Run terraform apply
  3. Drop the table
  4. Create the same table
  5. Run terraform plan or terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

Issue could potentially be around this line ->

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@dbieliaiev dbieliaiev added the bug Used to mark issues with provider's incorrect behavior label Jul 17, 2024
@sfc-gh-jmichalak sfc-gh-jmichalak added the resource:tag_association Issue connected to the snowflake_tag_association resource label Jul 17, 2024
@sfc-gh-jmichalak sfc-gh-jmichalak self-assigned this Oct 23, 2024
sfc-gh-jmichalak added a commit that referenced this issue Dec 5, 2024
<!-- Feel free to delete comments as you fill this in -->
- rework `tag_association` resource
- return `nil` from GetTag instead of failing
- add more tests regarding tag/masking policy: assert that `ALTER
MASKING POLICY SET TAG` differs from `ALTER TAG SET MASKING POLICY`
- support tagging account for identifiers with org name
- support `IF EXISTS` for unsetting tags
- add notes about manually unassigning policies from objects, add a todo
with an issue number
- fix a wrong issue number in essential objects 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/user-guide/object-tagging
https://docs.snowflake.com/en/sql-reference/functions/system_get_tag
#3145 
#1910 
#2943
#3235

## TODO
- use generated config and asserts, remove old test `tf` files

## Ideas
- extract a separate resource for tagging accounts?
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @dbieliaiev 👋

We've just released v0.100.0 (release, migration guide) in which we reworked tag associations. Unassigned tags should now be detected and corrected in terraform apply.
Please upgrade to this version and let us know if you have any issues.

@sfc-gh-jmichalak
Copy link
Collaborator

Closing due to inactivity.

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 resource:tag_association Issue connected to the snowflake_tag_association resource
Projects
None yet
Development

No branches or pull requests

2 participants