hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

Terraform reports Azure Diagnostic Setting as existing even though it is deleted. #14498

Closed prabirkrsarkar closed 2 years ago

prabirkrsarkar commented 2 years ago

Community Note

Terraform (and AzureRM Provider) Version

$ terraform -v Terraform v1.0.9 on linux_amd64

Affected Resource(s)

azurerm_monitor_diagnostic_setting

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

resource "azurerm_monitor_diagnostic_setting" "example" { name = "diagsettings" target_resource_id = data.azurerm_iothub.example.id log_analytics_workspace_id = data.azurerm_log_analytics_workspace.example.id

log { category = "Connections" enabled = true

retention_policy {
  enabled = true
}

}

log { category = "DeviceTelemetry" enabled = true

retention_policy {
  enabled = true
}

}

log {
category = "DistributedTracing"
enabled = true

retention_policy {
  enabled = true
}

}

metric { category = "AllMetrics" enabled = true

retention_policy {
  enabled = true
}

} }

Debug Output

Panic Output

Expected Behaviour

Actual Behaviour

Steps to Reproduce

  1. terraform apply

Important Factoids

References

tombuildsstuff commented 2 years ago

hi @prabirkrsarkar

Thanks for opening this issue.

Monitor Diagnostic Settings exist outside the lifecycle of the Resource Group - as such this won't be removed like other resources, as such since Terraform is finding this resource unfortunately this still exists in the API (and so needs to be imported).

This forum is intended to be used for feature enhancements and bugs in the Azure Provider - so that we can keep this forum focused on that we instead ask that broader questions are raised using one of the Community Resources. As such I'm going to close this issue for the moment, but I believe you should be able to get an answer for this using one of the Community Resources.

Thanks!

prabirkrsarkar commented 2 years ago

Thanks @tombuildsstuff. We figured out the same. Once we manually deleted the diag settings in the IoT hub and then deleted the resource group we could redeploy using terraform without any issues.

Thanks.

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.