-
Notifications
You must be signed in to change notification settings - Fork 428
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
Comments
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. |
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. |
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 ]
} |
<!-- 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)
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. |
Cured. Thank you. |
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
The text was updated successfully, but these errors were encountered: