Open ooteniya opened 1 year ago
Hi @ooteniya , thanks for submitting the issue!
I tried to reproduce the was present, but now absent
error with below config, but seems I can't. Could you please provide some detailed config to reproduce the error? Or some screenshot of json view of the activity log alert from Portal.
Experiencing the same issue
Resource_type: azurerm_monitor_activity_log_alert
Reproduce:
Error occurs randomly when deploying Activity Log Alert Rules
Resources are successfully deployed, but post-apply result fails and redeploy is not allowed because the resource already exists.
Occuring in TF version: 1.4.5, 1.4.6 and 1.5.1 (tested all)
Azurerm provider version: 3.59.0 and 3.61.0 tested
Raw Log: " 2023-06-27T17:56:27.1599272Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [20s elapsed] 2023-06-27T17:56:37.1600914Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [30s elapsed] 2023-06-27T17:56:47.1602589Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [40s elapsed] 2023-06-27T17:56:57.1604093Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [50s elapsed] 2023-06-27T17:57:07.1611172Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [1m0s elapsed] 2023-06-27T17:57:17.1612916Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [1m10s elapsed] 2023-06-27T17:57:27.1621752Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [1m20s elapsed] 2023-06-27T17:57:37.1630906Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [1m30s elapsed] 2023-06-27T17:57:47.1632734Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [1m40s elapsed] 2023-06-27T17:57:57.1639991Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [1m50s elapsed] 2023-06-27T17:58:07.1650755Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [2m0s elapsed] 2023-06-27T17:58:11.6111052Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Creation complete after 2m5s [id=/subscriptions/d952b48a-3183-48cf-8a23-8c6f7f5a302f/resourceGroups/rg-monitoringinfra-prd-eus2/providers/Microsoft.Insights/metricAlerts/mma-infra-virtualmachines-percentage-cpu-average-greaterthan-95-it-mgmt-prd] 2023-06-27T17:58:11.6581002Z 2023-06-27T17:58:11.6581675Z Error: Provider produced inconsistent result after apply 2023-06-27T17:58:11.6581921Z 2023-06-27T17:58:11.6582123Z When applying changes to 2023-06-27T17:58:11.6582437Z module.monitor_activity_log_alert["mala01"].azurerm_monitor_activity_log_alert.mala, 2023-06-27T17:58:11.6582683Z provider "provider[\"registry.terraform.io/hashicorp/azurerm\"].monitoring" 2023-06-27T17:58:11.6582881Z produced an unexpected new value: Root resource was present, but now absent. 2023-06-27T17:58:11.6582978Z 2023-06-27T17:58:11.6583401Z This is a bug in the provider, which should be reported in the provider's own 2023-06-27T17:58:11.6583552Z issue tracker. 2023-06-27T17:58:11.7126931Z ##[error]Terraform command 'apply' failed with exit code '1'.: Provider produced inconsistent result after apply 2023-06-27T17:58:11.7161003Z ##[error] Error: Provider produced inconsistent result after apply
When applying changes to module.monitor_activity_log_alert["mala01"].azurerm_monitor_activity_log_alert.mala, provider "provider[\"registry.terraform.io/hashicorp/azurerm\"].monitoring" produced an unexpected new value: Root resource was present, but now absent.
This is a bug in the provider, which should be reported in the provider's own issue tracker.
2023-06-27T17:58:11.8153744Z ##[section]Finishing: Deploy: Terraform Apply "
Experiencing the same issue
Resource_type: azurerm_monitor_activity_log_alert
Reproduce: Error occurs randomly when deploying Activity Log Alert Rules Resources are successfully deployed, but post-apply result fails and redeploy is not allowed because the resource already exists.
Occuring in TF version: 1.4.5, 1.4.6 and 1.5.1 (tested all)
Azurerm provider version: 3.59.0 and 3.61.0 tested
Raw Log: " 2023-06-27T17:56:27.1599272Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [20s elapsed] 2023-06-27T17:56:37.1600914Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [30s elapsed] 2023-06-27T17:56:47.1602589Z module.monitor_metric_alert["mma01"].azurerm_monitor_metric_alert.mma: Still creating... [40s elapsed] ...
Alert Rule category: VM Resource health
Scope: All Virtual Machines in Subscription
resource_type = "Microsoft.Compute/virtualMachines" operation_name = "Microsoft.Resourcehealth/healthevent/Activated/action"
Other Activity_Log_Alert_Rules deployed successfully
The Alert Rule resource for VM Resource health was deployed successfully and functional in Azure, but the task did not complete in the terraform log and was not written to the state file.
Workaround (3 successful tests on different subscriptions):
Possibly a timing issue?
Is there an existing issue for this?
Community Note
Terraform Version
0.12.31
AzureRM Provider Version
3.39.0
Affected Resource(s)/Data Source(s)
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Terraform should be able to create the resource group then action group and finally alert rules from scratch without running into issues
Actual Behaviour
After creating the resource group, action group and it starts creating the 13 alert rules, it fails on a different alert rules every time we retry it with the following error:
Note: example_alert alert rule is actually created in Azure, but is absent from the terraform state This looks very similar to #10371 but with different resources
Steps to Reproduce
Deploy 1 resource group, 1 action group, 50 alert rules. sometimes it succeeds sometimes fails
Important Factoids
No response
References
10371