payload: {"action":"closed","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/3793","repository_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm","labels_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/3793/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/3793/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/3793/events","html_url":"https://github.com/terraform-providers/terraform-provider-azurerm/issues/3793","id":464481535,"node_id":"MDU6SXNzdWU0NjQ0ODE1MzU=","number":3793,"title":"azurerm_recovery_services_protected_vm force new resource (recreate) instead of updating","user":{"login":"horpek","id":44053311,"node_id":"MDQ6VXNlcjQ0MDUzMzEx","avatar_url":"https://avatars1.githubusercontent.com/u/44053311?v=4","gravatar_id":"","url":"https://api.github.com/users/horpek","html_url":"https://github.com/horpek","followers_url":"https://api.github.com/users/horpek/followers","following_url":"https://api.github.com/users/horpek/following{/other_user}","gists_url":"https://api.github.com/users/horpek/gists{/gist_id}","starred_url":"https://api.github.com/users/horpek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/horpek/subscriptions","organizations_url":"https://api.github.com/users/horpek/orgs","repos_url":"https://api.github.com/users/horpek/repos","events_url":"https://api.github.com/users/horpek/events{/privacy}","received_events_url":"https://api.github.com/users/horpek/received_events","type":"User","site_admin":false},"labels":[{"id":620326282,"node_id":"MDU6TGFiZWw2MjAzMjYyODI=","url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/labels/enhancement","name":"enhancement","color":"d4c5f9","default":true},{"id":871855998,"node_id":"MDU6TGFiZWw4NzE4NTU5OTg=","url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/labels/service/recovery-services","name":"service/recovery-services","color":"00CC00","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2019-07-05T06:24:26Z","updated_at":"2019-11-18T11:04:21Z","closed_at":"2019-11-18T11:04:21Z","author_association":"NONE","body":"## Community Note\r\n•\tPlease vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request\r\n•\tPlease do not leave \"+1\" or \"me too\" comments, they generate extra noise for issue followers and do not help prioritize the request\r\n•\tIf you are interested in working on this issue or have submitted a pull request, please leave a comment\r\n\r\n## Terraform (and AzureRM Provider) Version\r\nTerraform v0.11.10\r\nAzureRM v1.31.0\r\n\r\n## Affected Resource(s)\r\n•\tazurerm_recovery_services_protected_vm\r\n\r\n## Terraform Configuration Files\r\nresource \"azurerm_recovery_services_protected_vm\" \"instance\" {\r\n  count               = \"${var.vm_settings[\"backup_policy\"] == \"none\" ? 0 : length(compact(local.vm_names))}\"\r\n\r\n  resource_group_name = \"${element(split(\"/\", var.recovery_vault_map[var.vm_settings[\"backup_policy\"]]), 4)}\"\r\n  recovery_vault_name = \"${element(split(\"/\", var.recovery_vault_map[var.vm_settings[\"backup_policy\"]]), 8)}\"\r\n  source_vm_id        = \"${element(azurerm_virtual_machine.instance.*.id, count.index)}\"\r\n  backup_policy_id    = \"${var.recovery_vault_map[var.vm_settings[\"backup_policy\"]]}\"\r\n\r\n  depends_on = [\"azurerm_virtual_machine.instance\"]\r\n}\r\n\r\n## Expected Behavior\r\nWhen we change the backup policy for the VM, terraform (or actually it is the azurerm provider) force a new resources instead of updating it.  This deletes all existing recovery points (i.e. backup images) taken with existing backup policy.  In Azure portal, it is an in place update called switching backup policy and it preserve all existing recovery points.\r\nActual Behavior\r\nTerraform deletes all recovery points, delete the protected_vm item and creates it.  \r\n\r\nAnd during this process, terraform issues the destroy and create instructions to Azure almost one after another and it causes a “locking issue”:\r\n11:14:22 2 error(s) occurred:\r\n11:14:22 \r\n11:14:22 * module.3bp0sv.azurerm_recovery_services_protected_vm.instance: 1 error(s) occurred:\r\n11:14:22 \r\n11:14:22 * azurerm_recovery_services_protected_vm.instance: Error waiting for the Recovery Service Protected VM \"VM;iaasvmcontainerv2;rsg-3bp0sv;rtpru322ououhsc\" to be true (Resource Group \"rsg-recoveryvault\") to provision: timeout while waiting for state to become 'Found' (last state: 'NotFound', timeout: 30m0s)\r\n11:14:22 * module.3bp0sv_1.azurerm_recovery_services_protected_vm.instance: 1 error(s) occurred:\r\n11:14:22 \r\n11:14:22 * azurerm_recovery_services_protected_vm.instance: Error waiting for the Recovery Service Protected VM \"VM;iaasvmcontainerv2;rsg-3bp0sv;rtpru3li4yk1t89\" to be true (Resource Group \"rsg-recoveryvault\") to provision: timeout while waiting for state to become 'Found' (last state: 'NotFound', timeout: 30m0s)\r\n\r\n \r\n\r\nThe error message from Azure activity log:\r\n{ \"Entity Name\": \"rtpru3li4yk1t89\", \"Job Id\": \"xxx77bf3-xxxx-xxxx-xxxx-2c6ff14b7xxx\", \"Start Time\": \"2019-07-05 02:44:20Z\", \"Failure Details\": \"Another operation is in progress on the selected item. If there is an in-progress operation, please retry after it has finished.\" }\r\n\r\n\"statusMessage\": \"{\\\"status\\\":\\\"Failed\\\",\\\"error\\\":{\\\"code\\\":\\\"ResourceOperationFailure\\\",\\\"message\\\":\\\"The resource operation completed with terminal provisioning state 'Failed'.\\\",\\\"details\\\":[\r\n{\\\"code\\\":\\\"BMSUserErrorObjectLocked\\\",\\\"message\\\":\\\"Another operation is in progress on the selected item.\\\"}\r\n \r\nRerunning the deployment after the first failure will trigger the creation (as the out-going protected_vm item is already destroyed) and ended successfully\r\n\r\n## Steps to Reproduce\r\n1.\tdeploy a VM with terraform and configure backup with azurerm_recovery_services_protected_vm.  Take a backup of the VM – this will create a recovery point.\r\n2.\tupdate the terraform configuration file with another backup_policy_id.\r\n3.\tRedeploy the terraform configuration and it will force new resource and will hit the error.  And the recovery point is deleted. \r\n"}}
other: {"actor":{"display_login":"tombuildsstuff"}}