DataDog / terraform-provider-datadog

Terraform Datadog provider
https://www.terraform.io/docs/providers/datadog/
Mozilla Public License 2.0
399 stars 375 forks source link

Provider produced inconsistent final plan - Replacing `-` with `_` in names of `datadog_metric_metadata.metric_description` #2432

Closed jonathanrainer closed 3 months ago

jonathanrainer commented 3 months ago

Datadog Terraform Provider Version

v3.39.0

Terraform Version

v1.7

What resources or data sources are affected?

datadog_metric_metadata.metric_description

Terraform Configuration Files

locals {
  functions = {
    ...
    "install-plugin" = {
      url_pattern = "..."
    },
    ...
  }
}

module "http_metrics_per_function" {
  source   = "./modules/custom_metric"
  for_each = local.functions
  ...
  name            = "orbiter.${each.key}.http.request"
  ...
}

resource "datadog_logs_metric" "this" {
  name = var.name
  ...
}

resource "datadog_metric_metadata" "metric_description" {
  metric          = datadog_logs_metric.this.name
  ...
}

Relevant debug or panic output

Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for
│ module.http_metrics_per_function["install-plugin"].datadog_metric_metadata.metric_description
│ to include new values learned so far during apply, provider
│ "registry.terraform.io/datadog/datadog" produced an invalid new value for
│ .metric: was cty.StringVal("orbiter.install-plugin.http.request"), but now
│ cty.StringVal("orbiter.install_plugin.http.request").
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Expected Behavior

The Terraform should have applied correctly with the name install-plugin rather than install_plugin

Actual Behavior

The Terraform errored with the error given above.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

nkzou commented 3 months ago

Hi, dashes are invalid in metric names per https://docs.datadoghq.com/metrics/custom_metrics/#naming-custom-metrics I'll keep this issue open to track adding provider-side validation for this case.