Cannot update Datadog Custom Metric Tag Configuration
Datadog Terraform Provider Version
3.43.1
Terraform Version
v1.5.7
What resources or data sources are affected?
datadog_metric_tag_configuration
Terraform Configuration Files
terraform {
required_providers {
datadog = {
source = "DataDog/datadog"
version = "3.43.1"
}
}
}
provider "datadog" {}
resource "datadog_metric_tag_configuration" "example_metric" {
metric_name = "example.metric"
metric_type = "gauge"
tags = ["eks", "account"]
}
Relevant debug or panic output
Error: error creating MetricTagConfiguration from https://api.datadoghq.com/api/v2/metrics/void.upstream.duration.median/tags: 409 Conflict: {"errors":["New gauge/count/rate conflicts with existing tag configuration, use PATCH to update"]}
Expected Behavior
I would expect the datadog provider to patch the custom metric tags
Actual Behavior
The datadog provider throws a 409 conflict error.
Steps to Reproduce
- Find a custom metric
- manually updated the tags. e.g. reduce to just
eks - apply tags that are different than the manual changes. e.g. add
account
resource "datadog_metric_tag_configuration" "example_metric" {
metric_name = "example.metric"
metric_type = "gauge"
tags = ["eks", "account"]
}
Important Factoids
No response
References
No response
Any update on this issue????
Hello, looks like the error message posted, it is coming from the following line specifically in the Create call. Based on this, it seems like the metric you are trying to modify is not currently managed by terraform and needs to be brought into terraform state using the import command: https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/metric_tag_configuration#import Additionally, we use the metric_name as the ID so updating manually via UI will not generate new ids.
Could you try importing and see if the error persists?
Based on this, it seems like the metric you are trying to modify is not currently managed by terraform and needs to be brought into terraform state using the import command
Sorry, the steps to reproduce are as follows.
- Find a custom metric
- Import the the custom metric to the
datadog_metric_tag_configurationresource. - Manually update the tags outside of terraform to create drift.
- Reapply the terraform and it will fail to correct the drift caused in step 2.
Additionally, we use the metric_name as the ID so updating manually via UI will not generate new ids.
Terraform resource id's do not support .. you will get this error:
╷
│ Error: Invalid resource name
│
│ on main.tf line 61, in resource "datadog_metric_tag_configuration" "example.metric":
│ 61: resource "datadog_metric_tag_configuration" "example.metric" {
│
│ A name must start with a letter or underscore and may contain only letters, digits, underscores, and dashes.
╵
Based on this, it seems like the metric you are trying to modify is not currently managed by terraform and needs to be brought into terraform state using the import command
Sorry, the steps to reproduce are as follows.
- Find a custom metric
- Import the the custom metric to the
datadog_metric_tag_configurationresource.- Manually update the tags outside of terraform to create drift.
- Reapply the terraform and it will fail to correct the drift caused in step 2.
Hello !
I tested your scenariobut I didn't achieve to reproduce your issue . I tested it in 2 cases : from a resource created by Terraform and from a resource imported. I tested with the 3.52.1 provider version. Could you please retest with the 3.52.1 ?
As said in the previous message, we were not able to reproduce your bug with recent version of the provider. Feel free to reopen (or create a new issue and link to this issue) if you still have the bug.