-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to destroy VM protected items #4276
Comments
Hi Rano, did you find a workaround for this solution? My plan wants to destroy these before applying the rest of the plan. |
unfortunately as stated in MicrosoftDocs/azure-docs#39329, there are no plans to revert the change or make it a toggle, similar to AKV. |
@Dev-Mivl , in my case, i will run |
The problem is that your Azure Backup Vault has configured Soft delete. As a resul the backup data is retained for 14 additional days, allowing the recovery of that backup item with no data loss. These additional 14 days retention of backup data in the "soft delete" state don’t incur any cost to the customer. |
@ranokarno, @ivanov-aleksander, Currently there is no way to turn off soft delete, and despite the API "soft-deleting" the VM it returns an error. This has been raised with the Azure service team and they have talked about potential fixes.. however i don't have date for when they will make the them. |
As there is a manual way (.1 deactivating soft state for the vault, 2.deleting backup data, 3. destroying the vault) this should be possible via API too. |
@ThoHah the API for disabling Soft Delete has only recently become available (in the last few weeks), so whilst this is likely now possible - unfortunately we've not gotten to it yet; there's an issue tracking support for this however :) |
Is it possible to add an option to retain backup data on destroy of the |
This issue concern azurerm 1.xx and azurerm_recovery_services_protected_vm.
|
@jcanongfi Yes it's still there. Destroying a |
It feels like here where we set up the target state and expect "NotFound" we should be able to pass multiple states in and allow for "NotFound" or "SoftDeleted" or whatever status they're returning. In my mind, if I tell terraform to destroy an item but it sits in soft-deleted state for 14 days, it's as good as gone (no expense, can be recreated). It might require an overload of the state.WaitForState() method to allow multiple states to be terminal states, but it feels like a good extension since we're likely to encounter this kind of thing on a variety of resources. I'm no go expert but I could give it a try if the idea is suitable to others. |
One point I have notice is while terraform apply returns "Still destroying", an e-mail is sent by Azure with the following content: "A delete Backup data alert has been activated so the backup is deleted, but the status seems not returned to terraform |
It would be nice to have an option on the "azurerm_backup_protected_vm" when it is added to say: ignore_soft_delete true/false Or even having an option that says: in_state true/false Something like "ignore_soft_delete true/false" would be ideal as it would be nice to when destroying a deployment that option allow the backup to be stopped and marked for deletion if "soft delete" was enabled on the RSV and allow a resource to be destroyed unhindered. |
Have we started looking into this yet? Currently removing state manually works but I don't think that should be the case as it hinders automation. |
The problem with the function that is deleting the backup is checking for the state of backup. Instead it should be looking first, if the backup has soft delete enabled. If soft delete is enabled, mark the backup for delete and ignore the change. Because if the backup is removed from state and somehow we dont want to delete it and we mark it manually as not to delete, then terraform deletes it anyway on the next run. I would do it this way,
Let me know if someone thinks this is good :) |
Any plans to pick this up? I have a rather large implementation and like soft to keep soft delete but have state reflect accurately when destroying with enabled. Agree those above that soft delete should = delete as it pertains to tfstate. |
Does someone knows a workaround ? Right now, I guess we have to:
Does not seems clean at all, even impossible in CI environments. |
@katbyte Have you heard anything more from the Azure service team on potential fixes? |
Sadly the workaround I have had to introduce to get around this problem is to manage the backups outside of Terraform. Not something I wanted to do, but I need my pipeline to manage my deployments of infrastructure in Azure and this one off rm of the resource object is a pretty poor workaround for scaling. Please add support for the soft delete API responses for the destroy of this resource type. |
Update, seems our issue is around the Soft Delete feature on the vault being enabled which causes the error: Error: waiting for the Azure Backup Protected VM to be false. context deadline exceeded |
This comment was marked as off-topic.
This comment was marked as off-topic.
At a minimum, I think items like this with a long history of issues should be flagged in the documentation. I was just testing some terraform to add the backup protected vm item and discovered the issue. There aren't any notes in the documentation and I had to come hunting in the issues section of the github page. This is completely backwards from a customer service perspective. If there are known issues, they should really be reflected in the docs so there is at least an opportunity to make a decision on using terraform to manage an item or not BEFORE I spin something up that I now have to perform state surgery on. This is extremely frustrating; especially in the current cybersecurity environment where we are all running around making sure our backups are managed better, are immutable, are tested, and we have full control on recovery. PLEASE do a better job on this in future. |
The soft-deleting seems to be supported by service now and added to the provider by #5586. I've done a test with I think it could cause more trouble to change the behavior of |
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. |
Community Note
Hi,
recently I am unable to delete VM protected items. I suspect this could be due to Azure backend change.
from Azure portal it mentioned VM is deleted in
deferred delete
but Terraform expectNot Found
Terraform (and AzureRM Provider) Version
Terraform v0.11.11
AzureRm 1.33.1
Affected Resource(s)
azurerm_recovery_services_protected_vm
Terraform Configuration Files
Expected Behavior
azurerm_recovery_services_protected_vm.vm1: destroy completed.
Actual Behavior
Steps to Reproduce
terraform apply
terraform destroy
The text was updated successfully, but these errors were encountered: