DataDog / terraform-provider-datadog

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

Error: Provider produced inconsistent result after apply #2415

Open Chaitu006 opened 5 months ago

Chaitu006 commented 5 months ago

Datadog Terraform Provider Version

3.38.0

Terraform Version

v1.3.7

What resources or data sources are affected?

datadog_apm_retention_filter

I tried upgrading to the latest(v3.39.0) and also downgrading the version to below and I still see the error, please take a look and let us know how to fix it.

provider "registry.terraform.io/datadog/datadog" { version = "3.38.0" constraints = "3.38.0"

provider "registry.terraform.io/hashicorp/aws" { version = "5.42.0" constraints = "5.42.0"

I tried to create APM retention filters using terraform, but when I try to terraform apply I see below error

Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ datadog_apm_retention_filter.showmetherent_listing_details_load_time,
│ provider "provider[\"http://registry.terraform.io/datadog/datadog%5C%22%5D%22  produced an
│ unexpected new value: .filter.query: was cty.StringVal("app:showmetherent
│ service:showmetherent-express env:production
│ @http.path_group:'/listing/details/?/?' @http.method:GET
│ @http.status_code:200 @duration:>600ms"), but now
│ cty.StringVal("app:showmetherent AND service:showmetherent\\-express AND
│ env:production AND @http.path_group:'/listing/details/?/?' AND
│ @http.method:GET AND @http.status_code:200 AND @duration:>600000000").
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ datadog_apm_retention_filter.showmetherent_listing_page_load_time, provider
│ "provider[\"http://registry.terraform.io/datadog/datadog%5C%22%5D%22  produced an
│ unexpected new value: .filter.query: was
│ cty.StringVal("service:showmetherent-express @http.path_group:'/listings'
│ app:showmetherent @http.method:HEAD env:production @http.status_code:200
│ @duration:>1500ms"), but now cty.StringVal("service:showmetherent\\-express
│ AND @http.path_group:'\\/listings' AND app:showmetherent AND
│ @http.method:HEAD AND env:production AND @http.status_code:200 AND
│ @duration:>1500000000").
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ datadog_apm_retention_filter.showmetherent_home_page_load_time, provider
│ "provider[\"http://registry.terraform.io/datadog/datadog%5C%22%5D%22  produced an
│ unexpected new value: .filter.query: was
│ cty.StringVal("service:showmetherent-express env:production
│ @http.path_group:'/' @http.method:GET app:showmetherent
│ @http.status_code:200 @duration:>600ms"), but now
│ cty.StringVal("service:showmetherent\\-express AND env:production AND
│ @http.path_group:'\\/' AND @http.method:GET AND app:showmetherent AND
│ @http.status_code:200 AND @duration:>600000000").
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

I'm using the latest provider version v3.39.0 (https://github.com/DataDog/terraform-provider-datadog/releases/tag/v3.39.0)

This is the code that I'm using to create these retention filters

Terraform Configuration Files

resource "datadog_apm_retention_filter" "showmetherent_home_page_load_time" {
  name        = "ShowMeTheRent Home Page Load Time"
  rate        = "1.0"
  filter {
    query     = "service:showmetherent-express env:production @http.path_group:'/' @http.method:GET app:showmetherent @http.status_code:200 @duration:>600ms"
  }
  filter_type = "spans-sampling-processor"
  enabled     = true
}

resource "datadog_apm_retention_filter" "showmetherent_listing_details_load_time" {
  name        = "ShowMeTheRent Listing Details Load Time"
  rate        = "1.0"
  filter {
    query     = "app:showmetherent service:showmetherent-express env:production @http.path_group:'/listing/details/?/?' @http.method:GET @http.status_code:200 @duration:>600ms"
  }
  filter_type = "spans-sampling-processor"
  enabled     = true
}

resource "datadog_apm_retention_filter" "showmetherent_listing_page_load_time" {
  name        = "ShowMeTheRent Listing Page Load Time"
  rate        = "1.0"
  filter {
    query     = "service:showmetherent-express @http.path_group:'/listings' app:showmetherent @http.method:HEAD env:production @http.status_code:200 @duration:>1500ms"
  }
  filter_type = "spans-sampling-processor"
  enabled     = true
}

Relevant debug or panic output

Error: Provider produced inconsistent result after apply │ │ When applying changes to │ datadog_apm_retention_filter.showmetherent_listing_details_load_time, │ provider "provider[\"registry.terraform.io/datadog/datadog\"]" produced an │ unexpected new value: .filter.query: was cty.StringVal("app:showmetherent │ service:showmetherent-express env:production │ @http.path_group:'/listing/details/?/?' @http.method:GET │ @http.status_code:200 @duration:>600ms"), but now │ cty.StringVal("app:showmetherent AND service:showmetherent\-express AND │ env:production AND @http.path_group:'/listing/details/?/?' AND │ @http.method:GET AND @http.status_code:200 AND @duration:>600000000"). │ │ This is a bug in the provider, which should be reported in the provider's │ own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent result after apply │ │ When applying changes to │ datadog_apm_retention_filter.showmetherent_home_page_load_time, provider │ "provider[\"registry.terraform.io/datadog/datadog\"]" produced an │ unexpected new value: .filter.query: was │ cty.StringVal("service:showmetherent-express env:production │ @http.path_group:'/' @http.method:GET app:showmetherent │ @http.status_code:200 @duration:>600ms"), but now │ cty.StringVal("service:showmetherent\-express AND env:production AND │ @http.path_group:'\/' AND @http.method:GET AND app:showmetherent AND │ @http.status_code:200 AND @duration:>600000000"). │ │ This is a bug in the provider, which should be reported in the provider's │ own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent result after apply │ │ When applying changes to │ datadog_apm_retention_filter.showmetherent_listing_page_load_time, provider │ "provider[\"registry.terraform.io/datadog/datadog\"]" produced an │ unexpected new value: .filter.query: was │ cty.StringVal("service:showmetherent-express @http.path_group:'/listings' │ app:showmetherent @http.method:HEAD env:production @http.status_code:200 │ @duration:>1500ms"), but now cty.StringVal("service:showmetherent\-express │ AND @http.path_group:'\/listings' AND app:showmetherent AND │ @http.method:HEAD AND env:production AND @http.status_code:200 AND │ @duration:>1500000000").

Expected Behavior

It should have created the retention filters

Actual Behavior

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

HantingZhang2 commented 3 months ago

Hi @Chaitu006 Currently our backend would rewrite the query into the format mentioned in the error message and terraform expect the returned the query to be the same as the provided one. That's why you are getting this error. In order to avoid this error, you can reformat your retention filter query into the same format mentioned in the error message