Skip to content

Commit 4d0e7b6

Browse files
author
oleh_mykolaishyn
committed
feat: support route table association
1 parent 5688294 commit 4d0e7b6

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ resource "azurerm_subnet_nat_gateway_association" "this" {
3333
subnet_id = var.export_subnet_id == null ? azurerm_subnet.this[0].id : var.export_subnet_id
3434
nat_gateway_id = var.nat_gateway_id
3535
}
36+
37+
resource "azurerm_subnet_route_table_association" "this" {
38+
count = var.route_table_association_enabled ? 1 : 0
39+
40+
subnet_id = var.export_subnet_id == null ? azurerm_subnet.this[0].id : var.export_subnet_id
41+
route_table_id = var.route_table_id
42+
}

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ output "nat_gateway_association_id" {
2323
description = "The ID of the NAT Gateway Association"
2424
}
2525

26+
output "route_table_association_id" {
27+
value = try(azurerm_subnet_route_table_association.this[0].id, null)
28+
description = "The ID of the Route Table Association"
29+
}
30+
2631
output "name_to_id_map" {
2732
value = var.export_subnet_id == null ? { (azurerm_subnet.this[0].name) = azurerm_subnet.this[0].id } : null
2833
description = "Map of Subnet Name to Id"

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ variable "nat_gateway_id" {
7373
description = "ID of the NAT Gateway which would be assigned to subnet"
7474
default = null
7575
}
76+
77+
variable "route_table_association_enabled" {
78+
type = bool
79+
description = "Boolean flag that determines if Route Table association would be created"
80+
default = false
81+
}
82+
83+
variable "route_table_id" {
84+
type = string
85+
description = "ID of the Route Table which would be assigned to subnet"
86+
default = null
87+
}

0 commit comments

Comments
 (0)