We could create multiple azure vms in a availability set using "count" loop.

How can we create the same using "for\_each" loop where the hostname and network interfaceid will be dynamic and looped over. (in terrraform > 0.12.6)

```
resource "azurerm_virtual_machine" "test" {

 # user provides inputs only for the number of vms to be created in the Azure avaialibility set

 count                 = var.count 
 name                  = "acctvm${count.index}"
 location              = azurerm_resource_group.test.location
 availability_set_id   = azurerm_availability_set.avset.id
 resource_group_name   = azurerm_resource_group.test.name
 network_interface_ids = [element(azurerm_network_interface.test.*.id, count.index)]
 vm_size               = "Standard_DS1_v2"
 tags                  = var.tags

```