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

Add support for tagging Snowflake Alert #2598

Closed
pei0804 opened this issue Mar 7, 2024 · 5 comments
Closed

Add support for tagging Snowflake Alert #2598

pei0804 opened this issue Mar 7, 2024 · 5 comments
Assignees
Labels
category:resource feature-request Used to mark issues with provider's missing functionalities resource:alert Issue connected to the snowflake_alert resource resource:tag_association Issue connected to the snowflake_tag_association resource

Comments

@pei0804
Copy link

pei0804 commented Mar 7, 2024

Terraform CLI and Provider Versions

Provider: v0.87.1
CLI: 1.7.4

Use Cases or Problem Statement

I am trying to add tags to Snowflake Alerts to identify the environment in which they are running. However, I discovered that neither snowflake_alert nor snowflake_tag_association resources in the Terraform Snowflake Provider support tagging for Alerts.

Currently, the only workaround is to manage the tagging of Alerts using a method other than the Terraform Snowflake Provider, which is not ideal.

By adding support for tagging Alerts in the Terraform Snowflake Provider, it would greatly simplify the management and organization of Alerts across different environments, making it easier to identify and track Alerts based on their associated tags.

Proposal

To address this issue, I propose extending the snowflake_tag_association resource to support tagging for Snowflake Alerts. This would be the most straightforward and consistent approach, as snowflake_tag_association is already used for tagging other Snowflake resources.

By updating the snowflake_tag_association resource to include support for Alerts, users would be able to easily manage and organize their Alerts using tags within the Terraform Snowflake Provider. This would provide a native, integrated solution for tagging Alerts, eliminating the need to rely on external methods or workarounds.

Implementing this solution would involve updating the provider's codebase to accept Alerts as a supported resource type for the snowflake_tag_association resource, along with any necessary modifications to handle the tagging process for Alerts specifically.

How much impact is this issue causing?

Medium

Additional Information

No response

@pei0804 pei0804 added the feature-request Used to mark issues with provider's missing functionalities label Mar 7, 2024
@pei0804 pei0804 changed the title Add support for tagging Snowflake Alerts in Snowflake Terraform Provider Add support for tagging Snowflake Alerts Mar 7, 2024
@pei0804 pei0804 changed the title Add support for tagging Snowflake Alerts Add support for tagging Snowflake Alert Mar 7, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @pei0804. Thanks for reaching out to us.

This is a good suggestion. We are in the process of redesigning the existing resources and adding the missing functionalities as part of https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#supporting-all-snowflake-ga-features). We will address it then.

@sfc-gh-asawicki
Copy link
Collaborator

For the time being, you can also use the https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/unsafe_execute resource. This is a dangerous resource, though. Please make sure to read the docs and familiarize yourself with the resource's limitations before using it.

@pei0804
Copy link
Author

pei0804 commented Mar 8, 2024

I implemented the code as follows and it worked successfully:

locals {
  database_name = "my_database"
  schema_name   = "my_schema"
}

resource "snowflake_alert" "this" {
...
}

resource "snowflake_unsafe_execute" "production_environment_tag_association" {
  count = var.is_production_environment ? 1 : 0
  execute = "ALTER ALERT ${local.database_name}.${local.schema_name}.${snowflake_alert.this.name} SET TAG SAMPLE_DATABASE.TAG.ENVIRONMENT = 'prod'"
  revert  = "ALTER ALERT ${local.database_name}.${local.schema_name}.${snowflake_alert.this.name} UNSET TAG SAMPLE_DATABASE.TAG.ENVIRONMENT"

  depends_on = [ snowflake_alert.this ]
}

@sfc-gh-jcieslak sfc-gh-jcieslak added resource:tag_association Issue connected to the snowflake_tag_association resource category:resource resource:alert Issue connected to the snowflake_alert resource labels May 20, 2024
sfc-gh-jmichalak added a commit that referenced this issue Oct 21, 2024
<!-- Feel free to delete comments as you fill this in -->

<!-- summary of changes -->
- add missing object types
(#1496,
#1862,
#2598)
- adjust show options
- add ifExists to tag queries
- add missing masking policy note about v1 rc
- add integration tests for setting, getting, and unsetting tags,
except:
  - failover group - business critical edition needed
  - alert, password policy, network policy - missing tag handling in SDK
- git repo, iceberg table, budget, classification, replication group -
objects not implemented in the sdk

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

## References
<!-- issues documentation links, etc  -->
https://docs.snowflake.com/en/sql-reference/sql/create-tag
https://docs.snowflake.com/en/user-guide/object-tagging
https://docs.snowflake.com/en/sql-reference/functions/system_get_tag

## TODO
- change GetTag to not fail on null values
- move tag assignments integration tests to a common place
- restrict the list of object types we want to support, instead of all
of them
- rework tag, tag_association resource
- remove tag_masking_policy_association_resource (tag_association will
be used instead)
@sfc-gh-jmichalak sfc-gh-jmichalak self-assigned this Oct 23, 2024
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @pei0804 👋

Alert tagging is now supported. Also, we've released a new v0.98.0 version (release, migration guide), we recommend upgrading to this version.

@pei0804
Copy link
Author

pei0804 commented Nov 13, 2024

Cured. Thank you.

@pei0804 pei0804 closed this as completed Nov 13, 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:alert Issue connected to the snowflake_alert resource resource:tag_association Issue connected to the snowflake_tag_association resource
Projects
None yet
Development

No branches or pull requests

4 participants