I am trying to use terraform to deploy a 3 NIC VM in Azure that will be used by an F5. I am using the following: I am receiving the following error:
Virtual Machine Name: “vm_f5npncus_vm02.corp.local”): performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with error: VirtualMachineMustHaveOneNetworkInterfaceAsPrimary: Virtual machine vm_f5npncus_vm02.corp.local must have one network interface set as the primary.
Snippet:
Network Interfaces
resource “azurerm_network_interface” “nic_f5npncus_vm02_mgmt” {
name = “nic-f5npncus-vm02-mgmt”
location = azurerm_resource_group.richard_playground.location
resource_group_name = azurerm_resource_group.richard_playground.name
ip_configuration {
primary = true
name = “ipconfig1”
subnet_id = azurerm_subnet.snet_edge_ncus_f5_mgmt.id
private_ip_address_allocation = “Static”
private_ip_address = “172.20.12.37”
}
}
resource “azurerm_network_interface” “nic_f5npncus_vm02_external” {
name = “nic-f5npncus-vm02-external”
location = azurerm_resource_group.richard_playground.location
resource_group_name = azurerm_resource_group.richard_playground.name
ip_configuration {
primary = false
name = “ipconfig1”
subnet_id = azurerm_subnet.snet_edge_ncus_f5_external.id
private_ip_address_allocation = “Static”
private_ip_address = “172.20.14.37”
}
}
resource “azurerm_network_interface” “nic_f5npncus_vm02_internal” {
name = “nic-f5npncus-vm02-internal”
location = azurerm_resource_group.richard_playground.location
resource_group_name = azurerm_resource_group.richard_playground.name
ip_configuration {
primary = false
name = “ipconfig1”
subnet_id = azurerm_subnet.snet_edge_ncus_f5_internal.id
private_ip_address_allocation = “Static”
private_ip_address = “172.20.100.37”
}
}
Virtual Machine
resource “azurerm_virtual_machine” “vm_f5npncus_vm02” {
name = “vm_f5npncus_vm02.corp.local”
location = azurerm_resource_group.richard_playground.location
resource_group_name = azurerm_resource_group.richard_playground.name
network_interface_ids = [
azurerm_network_interface.nic_f5npncus_vm02_mgmt.id, # Primary NIC
azurerm_network_interface.nic_f5npncus_vm02_external.id,
azurerm_network_interface.nic_f5npncus_vm02_internal.id
]