Open msapitree opened 9 months ago
Hi @msapitree , thanks for submitting this!
I can successfully reproduce the issue by changing the location
property of an existing data collection rule.
The expected Terraform behavior of this case is first detroy the azurerm_data_collection_rule_association
, and then destroy and re-create the azurerm_data_collection_rule
, finally recreate the association. But this is not happen because Terraform only want to update the association in place because the azurerm_data_collection_rule_association.data_collection_rule_id
is not forceNew
field. But from test, the rule accociated can be changed from one to another, so we didn't regard this as a forceNew
field.
A workaround for this is to add replace_triggered_by
for the azurerm_data_collection_rule_association
:
resource "azurerm_monitor_data_collection_rule_association" "example" {
name = "example-dcra"
target_resource_id = azurerm_kubernetes_cluster.example.id
data_collection_rule_id = azurerm_monitor_data_collection_rule.example.id
lifecycle {
replace_triggered_by = [azurerm_monitor_data_collection_rule.example]
}
}
Hi @teowa, thank you for the workaround - which I can confirm is working.
Thanks @teowa for the workaround.
Is there an existing issue for this?
Community Note
Terraform Version
1.5.7
AzureRM Provider Version
v3.88.0
Affected Resource(s)/Data Source(s)
azurerm_monitor_data_collection_rule
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
azurerm_monitor_data_collection_rule
should be successfully replaced, i.e. no error onterraform apply
If it means the resource has to be destroyed first, implying any association has to be destroyed too , then any such association should be deleted first and then, once the DCR is recreated, the association should be recreated too.
Actual Behaviour
Note: Resource Group, Subscription etc. are redacted
Steps to Reproduce
No response
Important Factoids
No response
References
No response