I have created standard VM in Azure which I have customized with different software on it. Then I have created an Azure Image from this VM and successfully imported that into the Azure Compute Gallery as an Image Version, so that I can deploy new VM based on the customized image faster with same configuration. I am able to deploy VMs of this nature using Terraform (with a single OS disk only), but now the source Image Version has multiple Data Disks included as well. Is it possible to deploy this customized image using Terraform including the Data Disks? And name each data disk with a custom name?
data "azurerm_shared_image_version" "existing" {
provider = azurerm.compute_gallery
name = var.compute_gallery.version
image_name = var.compute_gallery.definition
gallery_name = var.compute_gallery.name
resource_group_name = var.compute_gallery.resource_group_name
}
resource "azurerm_windows_virtual_machine" "windows_virtual_machine" {
name = var.virtual_machines[each.key].name
location = var.location
resource_group_name = var.resource_group_name
admin_password = "<__LOCALADMINPASSWORD__>"
admin_username = "<__LOCALADMINUSERNAME__>"
size = var.vmsize
network_interface_ids = [azurerm_network_interface.network_interface.id]
timezone = "GMT Standard Time"
provision_vm_agent = true
source_image_id = data.azurerm_shared_image_version.existing.id
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
name = lower(join("", ["disk-", var.virtual_machine_name, "-os"]))
}
Thank you
azurerm_windows_virtual_machine_scale_setsupports deploying from a gallery image version with data disk. I have this working successfully, however a normal VM using theazurerm_windows_virtual_machineresource does not support the data disks weirdly....