You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Destroying all VMs should not delete associated datadisks.
Actual Behavior
All OS and Datadisks get deleted when issuing command terraform destroy. When issuing command like terraform destroy -target=xxxx , datadisk remains intact only OS disk gets deleted.
Steps to Reproduce
1. Create multiple VMs in Azure with managed datadisks attached using Terraform apply`
2. When all VMs are up and all datadisks attached , destroy all VMs with `terraform destroy`
Result will be all OS and datadisks deleted with all data lost. Expect datadisks should not be deleted. Disks not visble in console Disk section.
3. Create all VMs again with terraform apply.
4. Destroy any one VM with command like terraform destroy -target=xxxx. Result will be VM is destroyed, OS disk is deleted and datadisk will still be intact in Azure console (Disk section).
5. Relaunch VM wth terraform apply -target=xxxx , original datadisk contents attached again and is reusable.
Additional Context
References
The text was updated successfully, but these errors were encountered:
In the Terraform Configuration referenced above the azurerm_managed_disk resource is specified, meaning the Data Disks are managed by Terraform and will be destroyed when terraform destroy is ran. It's worth noting that the delete_data_disks_on_termination flag is specific to Data Disks managed within the VM Resource (but these disks would still be deleted via the Resource Group being destroyed).
If these data disks need to live long term - as you've mentioned in the comment above, one option is to use taint to only destroy the Virtual Machine - the other would be to provision them in a separate configuration and then use the azurerm_managed_disk data source to reference them. It's worth noting that deleting the parent Resource Group will delete any data disks within it by design of Azure.
As this behaviour is intentional (since these resources are managed by Terraform) - I'm not sure there's anything we can do in this issue and as such I'm going to close this issue for the moment.
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.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!
ghost
locked and limited conversation to collaborators
Mar 30, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This issue was originally opened by @ajaybhatnagar as hashicorp/terraform#18581. It was migrated here as a result of the provider split. The original body of the issue is below.
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
Actual Behavior
Steps to Reproduce
Additional Context
References
The text was updated successfully, but these errors were encountered: