Skip to content

Commit d44323a

Browse files
authored
Merge pull request #12 from data-platform-hq/support_route_table_assoc
feat: support route table association
2 parents 5688294 + 62a6c03 commit d44323a

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ No modules.
2828
| [azurerm_subnet.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) | resource |
2929
| [azurerm_subnet_nat_gateway_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet_nat_gateway_association) | resource |
3030
| [azurerm_subnet_network_security_group_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet_network_security_group_association) | resource |
31+
| [azurerm_subnet_route_table_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet_route_table_association) | resource |
3132

3233
## Inputs
3334

@@ -44,6 +45,8 @@ No modules.
4445
| <a name="input_nsg_id"></a> [nsg\_id](#input\_nsg\_id) | The ID of the Network Security Group which should be associated with the Subnet | `string` | `null` | no |
4546
| <a name="input_private_endpoint_network_policies_enabled"></a> [private\_endpoint\_network\_policies\_enabled](#input\_private\_endpoint\_network\_policies\_enabled) | Enable or Disable network policies for the private link endpoint on the subnet. Setting this to true will Disable the policy and setting this to false will Enable the policy: [true\|false] | `bool` | `true` | no |
4647
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | The name of the resource group in which to create the storage account | `string` | n/a | yes |
48+
| <a name="input_route_table_association_enabled"></a> [route\_table\_association\_enabled](#input\_route\_table\_association\_enabled) | Boolean flag that determines if Route Table association would be created | `bool` | `false` | no |
49+
| <a name="input_route_table_id"></a> [route\_table\_id](#input\_route\_table\_id) | ID of the Route Table which would be assigned to subnet | `string` | `null` | no |
4750
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The list of Service endpoints to associate with the subnet: Microsoft.AzureActiveDirectory, Microsoft.AzureCosmosDB, Microsoft.ContainerRegistry, Microsoft.EventHub, Microsoft.KeyVault, Microsoft.ServiceBus, Microsoft.Sql, Microsoft.Storage, Microsoft.Web | `list(string)` | <pre>[<br> "Microsoft.Storage",<br> "Microsoft.KeyVault",<br> "Microsoft.Sql",<br> "Microsoft.Web"<br>]</pre> | no |
4851

4952
## Outputs
@@ -56,6 +59,7 @@ No modules.
5659
| <a name="output_name_to_id_map"></a> [name\_to\_id\_map](#output\_name\_to\_id\_map) | Map of Subnet Name to Id |
5760
| <a name="output_nat_gateway_association_id"></a> [nat\_gateway\_association\_id](#output\_nat\_gateway\_association\_id) | The ID of the NAT Gateway Association |
5861
| <a name="output_nsg_association_id"></a> [nsg\_association\_id](#output\_nsg\_association\_id) | The ID of the Network Security Group Association |
62+
| <a name="output_route_table_association_id"></a> [route\_table\_association\_id](#output\_route\_table\_association\_id) | The ID of the Route Table Association |
5963
<!-- END_TF_DOCS -->
6064

6165
## License

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)