-
Notifications
You must be signed in to change notification settings - Fork 305
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
Create data disks and attach after VM creation by azurerm_virtual_machine_data_disk_attachment resource. #227
Conversation
…hine_data_disk_attachment resource. This allows OS disks to be destroyed and recreated while leaving the data disks.
Hi @DatsloJRel , thanks for opening this pr, as
Now our virtual machine has |
@lonegunmanb , Thanks for looking at my PR!
My use case for this functionality is for redeployment of the VM with a newer OS disk (with latest OS patches, etc) while keeping the local data disk(s) deployed and untouched. I originally attempted this behavior by modifying the Through my research and testing, I was not able to perform the same behavior through the |
Thanks @DatsloJRel for your explanation, I got your point. You're right, the status quo cannot support your requirement: recreating virtual machine with newer os image meanwhile keeping the data disks, but we cannot add these I would recommend a new, modern virtual machine module -- terraform-azurerm-virtual-machine, which I believe can support your scenario. |
@lonegunmanb I can appreciate not wanting to add resources that can cause unpredictable behaviors. I added the extra text in the variables' description to help limit that behavior, but I can see more should be done. I would very much like to see this functionality added so that I don't have to maintain my separate fork, so I wonder if we can compromise? What if I added code such that it would prevent the creation of both and raise an error instead. Terraform v1.2.0 added the Disk Attachment Resource:
VM Resource:
|
Hi @DatsloJRel, I think we can make that happen, as you can see the current implementation's problem is as nested blocks, the data disk must be destroyed once we have to rebuild the vm. The solution is using standalone managed disk resources and attachment resources instead of nested blocks. We can do that by adding a new toggle, let's say |
Thanks @DatsloJRel for the update, almost LGTM and we finally get our e2e test runners work, but we have conflict in readme file. Would you please merge your branch with the latest master branch so we can merge this pr? Thanks! |
@lonegunmanb, I updated to use the Also, I am very interested to see how the modern virtual machine module -- terraform-azurerm-virtual-machine progresses. It looks like it will be a great option in the near future. Congratulations on it's initial release! I will most likely transition to that module once it is production ready. Thanks again for your help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @DatsloJRel, LGTM! 🚀
Describe your changes
Create data disks and attach after VM creation by azurerm_virtual_machine_data_disk_attachment resource.
This allows OS disks to be destroyed and recreated while leaving the data disks.
Checklist before requesting a review
CHANGELOG.md
fileThanks for your cooperation!