Terraform-provider-azurerm: Feature Request: new resource to attach disks to virtual machines

Created on 5 Feb 2018  ·  4Comments  ·  Source: terraform-providers/terraform-provider-azurerm

An issue that I have run into recently is the inability to use a count function when adding data disks to a VM storage configuration. I can create the data disks using a count function outside of the resource, but I have to specify multiple storage_data_disk items in the azurerm_virtual_machine resource to get them attached. Hashicorp is considering ways to added a count function within a resource (using the foreach terminology in this thread).

Rather than waiting for that approach to shake out, I would like to request that resources like azurerm_managed_disk support a mapping function to attach to a azurerm_virtual_machine resource, or that a new mapping resource be created that will map the attachment of the disk to the virtual machine, something like azurerm_managed_disk_attach. Here's an example of how that would work:

resource azurerm_managed_disk_attach {
  name  =  "disk-attach-${count.index}"
  count  =  "${var.number-of-disks}"
  disk_id  =  "${element(azurerm_managed_disk.mydisk.*.id, count.index)}"
  vm_id  =  "${azurerm_virtual_machine.mymachine.id}"
}
microsof3 new-resource servicvirtual-machine

Most helpful comment

This would be a huge benefit for us as well.

All 4 comments

This would be a huge benefit for us as well.

hey @ned1313

Thanks for opening this issue :)

This is something we'd like to support, but at the current time there's no matching API available for this in Azure. We may be able to workaround this by "faking" it - by placing a Lock on the Virtual Machine such that only one change can happen at a time - however this needs some investigation (hence I've added the "thinking" tag for the moment).

Thanks!

👋 hey all

I spent some time on Friday trying to work out how we'd achieve this and have opened #1207 which includes a new resource for attaching disks. This is still in an early phase and needs extensive testing - which we'll look into later in the week

Thanks!

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 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings