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

Error for inconsistent result after apply for Datadog Azure Integration #2413

Closed szc1wz closed 3 months ago

szc1wz commented 4 months ago

Datadog Terraform Provider Version

v3.34

Terraform Version

v1.8.3

What resources or data sources are affected?

datadog_integration_azure

Terraform Configuration Files

data "azurerm_client_config" "current" {}

resource "datadog_integration_azure" "datadog_azure_integration" {
  tenant_name   = data.azurerm_client_config.current.tenant_id
  client_id     = var.datadog_app_registration_id
  client_secret = var.datadog_app_registration_password
}

Relevant debug or panic output

│ Error: Provider produced inconsistent result after apply │ │ When applying changes to │ datadog_integration_azure.datadog_azure_integration, provider │ "provider[\"registry.terraform.io/datadog/datadog\"]" produced an │ unexpected new value: .id: was │ cty.StringVal(":ef0d7733-c2d5-45f6-xxxxx-xxxxxx"), │ but now │ cty.StringVal(":***"). │ │ This is a bug in the provider, which should be reported in the provider's │ own issue tracker.

Expected Behavior

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Actual Behavior

If the resource already exists, the terraform apply fails to update it.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

HantingZhang2 commented 4 months ago

Hi @szc1wz , I suppose you are trying to update client_id or tenant_name ? For those updates you can use terraform apply -replace="datadog_integration_azure.<your_resource_name>"

As those changes will result in the change of the resource's id, the -replace flag allows for the creation of a new resource.

szc1wz commented 3 months ago

Hello @HantingZhang2, sorry for the late response, and thank you for your advice. It did work, however, the -replace attribute should be added to terraform plan command and not apply, like this: terraform plan -replace="datadog_integration_azure.<your_resource_name>"