terraform-provider-azurerm: azurerm_linux_virtual_machine does not support data disks which is blocking for cloud-init configuration

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave β€œ+1” or β€œme too” comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Affected Resource(s)

  • azurerm_linux_virtual_machine

Important Factoids

The azurerm_virtual_machineresource supports data_disks, but this isn’t possible with the new azurerm_linux_virtual_machine or azurerm_windows_virtual_machine.

[edit]

As soon as the vm is created, the cloud-init initialization starts. As we can not attach a data disk in a single operation with azurerm_linux_virtual_machine, we can not mount nor do anything with the data disk during the cloud-init operation.

However, it’s pretty common (a best practice) to

  • use cloud-init for vm initialization
  • rely on a data disk for persistent data

πŸ‘‰ This use case is not possible anymore. 😒

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 47
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Thanks @ArcturusZhang for your answer.

But having a separate resource for that does not enable my use case, where the custom data script (a cloud-init script) mount the data disk volume and do stuff on it.

Reporting error relating to this issue

Message="StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile." Target="storageProfile"

Similar to the error you see for the windows virtual machine resource #6004

Hi @boillodmanuel thanks for this issue, but in 2.0 the azurerm_linux_virtual_machine (as well as azurerm_windows_virtual_machine) must use the new resource azurerm_virtual_machine_data_disk_attachment to attach data disk for them. Here is the doc page for azurerm_virtual_machine_data_disk_attachment: https://www.terraform.io/docs/providers/azurerm/r/virtual_machine_data_disk_attachment.html