From ea22fa520a4184cf49e1efe1e14981658e99cee4 Mon Sep 17 00:00:00 2001 From: eddiek Date: Thu, 28 Nov 2024 10:00:09 +0000 Subject: [PATCH] Azure TF templates | Aligned route tables --- terraform/azure/modules/vnet/main.tf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) } }