-
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
r/(linux|windows)_virtual_machine - support for managed_disk_id
from an existing OS disk
#8195
Comments
hey @jpbuecken Thanks for opening this issue. When building the new VM Resources we intentionally omitted these fields since whilst Azure still supports this pattern - it's generally recommended to use a new OS Disk where possible (for example sourced from an image, which could be an existing image of an OS Disk). Whilst we may look to re-add the As such for the moment I'm going to update this issue to focus on supporting attaching existing OS disks to the new virtual machine resources - since we don't plan to expose the Thanks! |
managed_disk_id
from an existing OS disk
managed_disk_id
from an existing OS diskmanaged_disk_id
from an existing OS disk
Agree and I'm totally fine with that. |
We create our Azure VM's with azurerm_windows_virtual_machine and a generalized image from shared image gallery, which works great. We do use Azure recovery services vault for backup of these VMs. This is a disk level backup. If we need to restore the OS disk, this recovery creates a new disk that we then attach to the VM, putting the config out of sync. If we try to import the resulting VM config, we get the same error: Error: The "azurerm_windows_virtual_machine" resource doesn't support attaching OS Disks - please use the azurerm_virtual_machine resource instead There doesn't seem to be a way to use azurerm_windows_virtual_machine with Azure Recovery Services Vault and OS disk restores, which seems to be a major problem. |
I want to mention another use case: The official Azure Migrate service does create a VM from disk. Thus we cannot import VMs created by Azure Migrate to terraform, unless we use the deprecated resource azurerm_virtual_machine. How is the actual state of this issue? The provider should support import of VMs created by Azure Migrate. I assume this is a use case that will hopefully help to prioritize this issue. Any known workarounds to my specific case? |
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
The attach option for the OS disk (ZRS stroage) is the only solution, to migrate all VMs from one AZ to another (in an AZ failure case). |
I agree or at least it is the cleanest one. Also for importing existing VMs created with OS disk attached into terraform this is the only (clean) way. For most of appliances prepared as images from vendors this is literally the only way. |
We have similar issue when we do ASR and want to get the machine created by ASR under terraform management.
The os disk id output would also nice for the original VM because the os disk ID is required to setup ASR through terraform. Right now we have to use an external script resource to get the os disk ID for ASR with terraform. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@tombuildsstuff Thank you for your reply! Do you know when this functionality will be added to the Thank you for your reply! Do you know when this functionality will be added to the azurerm_linux_virtual_machine and azurerm_windows_virtual_machine resources? if not soon then we will use azurerm_virtual_machine resource. |
Using azurerm_virtual_machine cannot be the answer because it has no feature parity. E.g. azurerm_virtual_machine does not support license_type the same way as azurerm_linux_virtual_machine, capacity reservations are not supported etc. |
@jackofallops what were the technical limitations in your implementation: #10466 (comment) |
Would a possible workaround be to convert the virtual os_disk to a Specialized image using the azurerm_image resource and then deploy the VM from the image? |
Community Note
Description
We want to build an instance from a pre-defined managed disk. You forgot to adopt this feature from azurerm_virtual_machine in the new azurerm_*_virtual_machine.
In the legacy resource you could do the following:
New or Affected Resource(s)
Potential Terraform Configuration
References
Use case is to manage metadata of the OS disk. The details are described here:
EDIT:
After comment from @tombuildsstuff I removed
create_option = "Attach"
from the "Potential Terraform Configuration" hcl, since "it should be managed by Terraform due to the quirks behind it"The text was updated successfully, but these errors were encountered: