diff --git a/terraform/azure/modules/vnet/main.tf b/terraform/azure/modules/vnet/main.tf index 2c67fc4f..17127b07 100755 --- a/terraform/azure/modules/vnet/main.tf +++ b/terraform/azure/modules/vnet/main.tf @@ -36,6 +36,7 @@ locals { // locals for 'next_hop_type' allowed values "VirtualAppliance", "None" ] + address_prefix_length = length(var.subnet_prefixes[0]) } resource "azurerm_route_table" "frontend" { @@ -51,7 +52,8 @@ resource "azurerm_route_table" "frontend" { route { name = "To-Internal" address_prefix = var.address_space - next_hop_type = local.next_hop_type_allowed_values[4] + next_hop_type = local.next_hop_type_allowed_values[3] + next_hop_in_ip_address = substr(replace(azurerm_subnet.subnet[0].address_prefixes[0], "0/", "4/"), 0, local.address_prefix_length - 3) } } @@ -69,7 +71,8 @@ resource "azurerm_route_table" "backend" { route { name = "To-Internet" address_prefix = "0.0.0.0/0" - next_hop_type = local.next_hop_type_allowed_values[4] + next_hop_type = local.next_hop_type_allowed_values[3] + next_hop_in_ip_address = substr(replace(azurerm_subnet.subnet[1].address_prefixes[0], "0/", "4/"), 0, local.address_prefix_length - 3) } }