jmlp1 / JMA-AZURE

0 stars 0 forks source link

multiple nics / vms / index #3

Closed jmlp1 closed 1 month ago

jmlp1 commented 1 month ago

Error: Invalid function argument │ │ on main.tf line 25, in resource "azurerm_network_interface" "nic": │ 25: for_each = toset(split(",", var.vm_names)) │ ├──────────────── │ │ while calling split(separator, str) │ │ var.vm_names is a list of string │ │ Invalid value for "str" parameter: string required.

jmlp1 commented 1 month ago

Resolved

resource "azurerm_network_interface" "nic" { name = "primaryNic${count.index}" location = azurerm_resource_group.arg.location resource_group_name = azurerm_resource_group.arg.name count = 2 ip_configuration { name = "internal" subnet_id = azurerm_subnet.subnet.id private_ip_address_allocation = "Dynamic" } }

resource "azurerm_virtual_machine" "vm" { name = "vm${count.index}" location = "${azurerm_network_interface.nic[count.index].location}" resource_group_name = azurerm_resource_group.arg.name network_interface_ids = ["${azurerm_network_interface.nic[count.index].id}"] vm_size = "Standard_DS1_v2"