Hi there, new to terraform, so apologies if this is covered elsewhere (a search didn’t turn up anything, but I might not know the right syntax).
I have a resource (VM) in Azure that I’m trying to create, but it fails due to a bug in Azure if it’s created with >1 NIC. However, if created with 1 NIC, then it’s fine.
So, to work around the bug, I need to create the VM with the 1 NIC, then add the second NIC after it’s created. I know this works in Azure and works around the bug.
If I create a terraform resource with the 1 nic, trun the apply, then update the configuration file, and run the apply the second time, it all works great!
However, I can’t work out a way to get terraform to do this without me modifying the terraform file in between runs (which rather runs counter to my automation strategy!).
Relevant code, if it helps:
resource “azurerm_linux_virtual_machine” “edgeconnectvm” {
name = local.edgeconnect_vmname
location = data.azurerm_resource_group.edgeconnect_resource_group.location
resource_group_name = data.azurerm_resource_group.edgeconnect_resource_group.name
availability_set_id = azurerm_availability_set.example.id
size = “Standard_D2s_v3”
admin_username = “”
network_interface_ids = [
azurerm_network_interface.WAN_NIC.id,
azurerm_network_interface.VNET_NIC.id,
]
os_disk {
caching = "ReadWrite"
storage_account_type = "Premium_LRS"
}
source_image_reference {
publisher = local.publisher
offer = local.product
sku = local.edgeconnect_sku
version = local.edgeconnect_version
}
plan {
publisher = local.publisher
product = local.product
name = local.edgeconnect_sku
}
boot_diagnostics {
storage_account_uri = azurerm_storage_account.diags.primary_blob_endpoint
}