diff --git a/_example/default_subnet/example.tf b/_example/default_subnet/example.tf index 7c51729..99cae99 100644 --- a/_example/default_subnet/example.tf +++ b/_example/default_subnet/example.tf @@ -49,3 +49,29 @@ module "subnet" { } ] } + +module "subnet_2" { + source = "../.." + + name = "app" + environment = "test" + + resource_group_name = module.resource_group.resource_group_name + location = module.resource_group.resource_group_location + virtual_network_name = join("", module.vnet.vnet_name) + + #subnet + subnet_names = ["sub3", "sub4"] + subnet_prefixes = ["10.0.3.0/24", "10.0.4.0/24"] + + # route_table + enable_route_table = true + route_table_name = "test_rt" + routes = [ + { + name = "rt-test" + address_prefix = "0.0.0.0/0" + next_hop_type = "Internet" + } + ] +} diff --git a/_example/name-specific_subnet/example.tf b/_example/name-specific_subnet/example.tf index 8b57ebf..9a53335 100644 --- a/_example/name-specific_subnet/example.tf +++ b/_example/name-specific_subnet/example.tf @@ -40,7 +40,8 @@ module "name_specific_subnet" { subnet_prefixes = ["10.0.1.0/24"] # route_table - route_table_name = "name_specific_subnet" + enable_route_table = true + route_table_name = "name_specific_subnet" routes = [ { name = "rt-test" diff --git a/_example/nat-gateway_subnet/example.tf b/_example/nat-gateway_subnet/example.tf index a8d2559..24fd48e 100644 --- a/_example/nat-gateway_subnet/example.tf +++ b/_example/nat-gateway_subnet/example.tf @@ -40,7 +40,8 @@ module "subnet" { subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"] # route_table - route_table_name = "nat_gateway" + enable_route_table = true + route_table_name = "nat_gateway" routes = [ { name = "rt-test" diff --git a/main.tf b/main.tf index 44b7a79..281388f 100644 --- a/main.tf +++ b/main.tf @@ -105,7 +105,7 @@ resource "azurerm_subnet_nat_gateway_association" "subnet_assoc" { #Route Table resource "azurerm_route_table" "rt" { count = var.enable && var.enable_route_table ? 1 : 0 - name = format("%s-%s-route-table", module.labels.id, var.route_table_name) + name = var.route_table_name == null ? format("%s-route-table", module.labels.id) : format("%s-%s-route-table", module.labels.id, var.route_table_name) location = var.location resource_group_name = var.resource_group_name dynamic "route" { diff --git a/variable.tf b/variable.tf index 693c11c..0b5daa5 100644 --- a/variable.tf +++ b/variable.tf @@ -167,7 +167,7 @@ variable "routes" { variable "route_table_name" { type = string - default = "" + default = null description = "The name of the route table." }