- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
12-01-2020 01:58 PM
I am trying to create multiple vms and managed disk to associate after creation. I could see the disks are created and getting associated only for the first VM in the list. I am not sure how to assign the right index number in the below code.
I believe Virtual_Machine_id is creating this issue, has any one came across the similar, please advice.
'''resource “azurerm_managed_disk” “app_managed_disk” { count = “${length(var.data_disk_names)}” name = “ var.apphostname−{var.data_disk_names[count.index %length(var.data_disk_names)]}” location = azurerm_resource_group.poc_rg.location resource_group_name = azurerm_resource_group.poc_rg.name storage_account_type = var.app_disk_type create_option = “Empty” disk_size_gb = “${var.data_disk_sizes[count.index % length(var.data_disk_sizes)]}” } resource “azurerm_virtual_machine_data_disk_attachment” “app_disk_attach” { count = “${length(var.data_disk_names)}” vm_count = length(var.vm_app_name) managed_disk_id = “${azurerm_managed_disk.app_managed_disk[count.index % length(azurerm_managed_disk.app_managed_disk)].id}” virtual_machine_id = azurerm_linux_virtual_machine.app-vm-pas[0].id lun = “${count.index + 1}” caching = “ReadWrite” }
'''
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!