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]: Terraform import of snowflake_tag_association is not working correctly #3145

Open
1 task
saugandhik-kipi opened this issue Oct 21, 2024 · 3 comments
Open
1 task
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior resource:tag_association Issue connected to the snowflake_tag_association resource

Comments

@saugandhik-kipi
Copy link

Terraform CLI Version

1.9.8

Terraform Provider Version

0.97.0

Terraform Configuration

While trying to import an existing terraform resource of snowflake_tag_association 
using the below statement -
terraform import snowflake_tag_association.example 'ANALYTICS_PRODUCTION_DB.SNAPSHOTS.ON_CHURN_ARCHIVE'

as per the documentation.
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/tag_association 
# format is dbName.schemaName.tagName or dbName.schemaName.tagName
terraform import snowflake_tag_association.example 'dbName.schemaName.tagName'


But while looking at the terraform state file I am not able to understand why everything is blank.
So this import statement is not able to import the resource correctly. 
Please help me on this.

Category

category:resource

Object type(s)

No response

Expected Behavior

expected would be all the attributes should have value like below -
resource "snowflake_tag_association" "table_association" {
object_identifier {
name = snowflake_table.test.name
database = snowflake_database.test.name
schema = snowflake_schema.test.name
}
object_type = "TABLE"
tag_id = snowflake_tag.test.id
tag_value = "engineering"
}

Actual Behavior

{
"address": "module.tag.snowflake_tag_association.example",
"mode": "managed",
"type": "snowflake_tag_association",
"name": "example",
"provider_name": "registry.terraform.io/snowflake-labs/snowflake",
"schema_version": 0,
"values": {
"id": "ANALYTICS_PRODUCTION_DB.SNAPSHOTS.ON_CHURN_ARCHIVE.ANALYTICS_PRODUCTION_DB.SNAPSHOTS.PG__INSTITUTIONS_SNAPSHOT",
"object_identifier": [],
"object_name": null,
"object_type": null,
"skip_validation": null,
"tag_id": null,
"tag_value": null,
"timeouts": null
},
"sensitive_values": {
"object_identifier": []
}
}
],
"address": "module.tag"
},

Steps to Reproduce

Import any tag association in terraform state.

How much impact is this issue causing?

High

Logs

No response

Additional Information

image

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@saugandhik-kipi saugandhik-kipi added the bug Used to mark issues with provider's incorrect behavior label Oct 21, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @saugandhik-kipi. Thanks for reaching out to us.

@sfc-gh-jmichalak is currently working on the tags redesign, so he will check this issue during that work.

@saugandhik-kipi
Copy link
Author

saugandhik-kipi commented Oct 21, 2024 via email

@sfc-gh-jmichalak sfc-gh-jmichalak self-assigned this Oct 23, 2024
@sfc-gh-jmichalak sfc-gh-jmichalak added the resource:tag_association Issue connected to the snowflake_tag_association resource label 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 @saugandhik-kipi 👋

We've just released v0.100.0 (release, migration guide) in which we reworked tag associations. Please mind the limitations:
Due to technical limitations of Terraform SDK, object_identifiers are not set during the import state. Please run terraform refresh after importing to get this field populated. object_type, tag_id and tag_value should be populated correctly.

Please upgrade to this version and let us know if you have any issues.

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

3 participants