Vsphere_virtual_machine dynamic number of additional disks

Hi,

I read values from a map of a lot of different machines, it’s always a cloned template, but sometimes I need to provide extra disks

my idea was to use a size of 0 for no second disk, and then count to create the disk, or not.
the problem, a disk is a change I guess and no creation so count will not work.

it looks something like this:

>  disk {
>     label = "disk0"
>     size  = 20
>     unit_number = 0
>     thin_provisioned = true
>   }
> 
> 
>   disk {
>     count = each.value.my_data_disk ? 0 : 0
>     label = "disk1"
>     size  = each.value.my_data_disk
>     unit_number = 1
>     thin_provisioned = true
>   }

what I need is an if statement to skip the second part, this is not possible ofc.

maybe you have an idea how to achieve this

since I need to create 60 vms at once I decided to use terraform and this is my first project at all and my first forum post, so hi @ all and thanks in advance :smiley:

cheers