Skip to content

Commit

Permalink
hurodata[48] Fix - multiple route tables can be created in the same v…
Browse files Browse the repository at this point in the history
…net (fixed the naming format in route table resource)
  • Loading branch information
nileshgadgi committed Apr 4, 2023
1 parent b736279 commit 994bfea
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
26 changes: 26 additions & 0 deletions _example/default_subnet/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
3 changes: 2 additions & 1 deletion _example/name-specific_subnet/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion _example/nat-gateway_subnet/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ variable "routes" {

variable "route_table_name" {
type = string
default = ""
default = null
description = "The name of the route table."
}

Expand Down

0 comments on commit 994bfea

Please sign in to comment.