My terraform code:
data "azurerm_virtual_hub" "vhub" {
provider = azurerm.ss101
name = "..."
resource_group_name = local.vhub_rg_name
}
resource "azurerm_virtual_network" "managed_vnet" {
name = "..."
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
address_space = v.cidr
...
}
resource "azurerm_virtual_hub_connection" "spoke" {
provider = azurerm.ss101
name = "${var.app_vnet.name}-connection"
virtual_hub_id = data.azurerm_virtual_hub.vhub.id
remote_virtual_network_id=azurerm_virtual_network.managed_vnet.id
internet_security_enabled = true
routing {
associated_route_table_id = "..."
propagated_route_table {
route_table_ids = [
for region in keys(local.transit_map) : "..."
]
labels = ["default"]
}
}
}
Currently, in order to update vnet CIDR, I need plan and apply my terraform 3 times: 1. destroy the vnet peering with the virtual hub; 2. update vnet CIDR; 3 recreate the vnet peering with the virtual hub.
Is it possible to let the azurerm
provider to recognize this situation and to plan to recreate the Virtual Hub connection? I want to run my terraform only 1 time, which is to recreate the virtual hub connection when updating vnet cidr.