Unexpected Terraform Behaviour: Unable to delete Module Resources

Terraform is unable to delete all the resources from a module. Even though we have all resources information in the state file related to it. Hence state file is not corrupted, still it deletes only half of the dependent resources like adf’s private endpoint and time_sleep

Here is the logs summary in short when we perform terraform destroy:

module.data_factory.module.data_factory.azurerm_data_factory.azurerm_df: Refreshing state… [id=/subscriptions/<sub_id>/resourceGroups/providers/Microsoft.DataFactory/factories/adf]

module.data_factory.module.data_factory.azurerm_private_endpoint.data_factory: Refreshing state… [id=/subscriptions/<sub_id>/resourceGroups//providers/Microsoft.Network/privateEndpoints/pe-adf]

module.data_factory.module.data_factory.azurerm_monitor_diagnostic_setting.diag: Refreshing state… [id=/subscriptions/<sub_id>/resourceGroups//providers/Microsoft.DataFactory/factories/adf|log_analytics]

module.data_factory.module.azure_integration_runtime[0].azurerm_data_factory_integration_runtime_azure.this: Refreshing state… [id=/subscriptions/<sub_id>/resourceGroups//providers/Microsoft.DataFactory/factories/adf/integrationruntimes/AZIR]

module.data_factory.module.data_factory.time_sleep.wait_for_pe_ready: Refreshing state…

Terraform will perform the following actions:

module.data_factory.module.data_factory.azurerm_private_endpoint.data_factory will be destroyed

module.data_factory.module.data_factory.time_sleep.wait_for_pe_ready will be destroyed

==============================================end of log

It deletes only above two reosurces, leaving other 3 resources as it is. It doesn’t delete and if we recreates, it try to create again adf. However, creating “azurerm_monitor_diagnostic_setting” gives an error stating already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for “azurerm_monitor_diagnostic_setting” for more information.

I checked in my local environment, it works fine but in production env, it fails to delete.

Can we have any update on this please?