Skip to content

Commit 4d005bc

Browse files
authored
Add Tags to Route Table and Public IPs (#76)
1 parent de5b10d commit 4d005bc

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ README-generated.md
5353

5454
# Certificate files generated by examples
5555
**/*.pem
56+
57+

locals.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ locals {
3434
location = local.virtual_networks_modules[vnet_name].vnet_location
3535
name = try(vnet.firewall.default_ip_configuration.public_ip_config.name, "pip-afw-${vnet_name}")
3636
resource_group_name = vnet.resource_group_name
37+
tags = vnet.firewall.default_ip_configuration.tags
3738
ip_version = try(vnet.firewall.default_ip_configuration.public_ip_config.ip_version, "IPv4")
3839
sku_tier = try(vnet.firewall.default_ip_configuration.public_ip_config.sku_tier, "Regional")
3940
zones = try(vnet.firewall.default_ip_configuration.public_ip_config.zones, null)
@@ -44,6 +45,7 @@ locals {
4445
location = local.virtual_networks_modules[k].vnet_location
4546
name = try(v.firewall.management_ip_configuration.public_ip_config.name, "pip-afw-mgmt-${k}")
4647
resource_group_name = v.resource_group_name
48+
tags = v.firewall.management_ip_configuration.tags
4749
ip_version = try(v.firewall.management_ip_coniguration.public_ip_config.ip_version, "IPv4")
4850
sku_tier = try(v.firewall.management_ip_coniguration.public_ip_config.sku_tier, "Regional")
4951
zones = try(v.firewall.management_ip_coniguration.public_ip_config.zones, null)

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ resource "azurerm_route_table" "hub_routing" {
7575
name = coalesce(var.hub_virtual_networks[each.key].route_table_name, "route-${each.key}")
7676
resource_group_name = try(azurerm_resource_group.rg[var.hub_virtual_networks[each.key].resource_group_name].name, var.hub_virtual_networks[each.key].resource_group_name)
7777
disable_bgp_route_propagation = false
78-
tags = {}
78+
tags = var.hub_virtual_networks[each.key].route_table_tags
7979

8080
route {
8181
address_prefix = "0.0.0.0/0"
@@ -128,7 +128,7 @@ resource "azurerm_public_ip" "fw_default_ip_configuration_pip" {
128128
ip_version = each.value.ip_version
129129
sku = "Standard"
130130
sku_tier = each.value.sku_tier
131-
tags = {}
131+
tags = each.value.tags
132132
zones = each.value.zones
133133
}
134134

@@ -142,7 +142,7 @@ resource "azurerm_public_ip" "fw_management_ip_configuration_pip" {
142142
ip_version = each.value.ip_version
143143
sku = "Standard"
144144
sku_tier = each.value.sku_tier
145-
tags = {}
145+
tags = each.value.tags
146146
zones = each.value.zones
147147
}
148148

variables.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ variable "hub_virtual_networks" {
55
location = string
66
resource_group_name = string
77
route_table_name = optional(string)
8+
route_table_tags = optional(map(string))
89
bgp_community = optional(string)
910
ddos_protection_plan_id = optional(string)
1011
dns_servers = optional(list(string))
@@ -71,6 +72,7 @@ variable "hub_virtual_networks" {
7172
zones = optional(list(string))
7273
default_ip_configuration = optional(object({
7374
name = optional(string)
75+
tags = optional(map(string))
7476
public_ip_config = optional(object({
7577
ip_version = optional(string)
7678
name = optional(string)
@@ -80,6 +82,7 @@ variable "hub_virtual_networks" {
8082
}))
8183
management_ip_configuration = optional(object({
8284
name = optional(string)
85+
tags = optional(map(string))
8386
public_ip_config = optional(object({
8487
ip_version = optional(string)
8588
name = optional(string)
@@ -114,6 +117,8 @@ A map of the hub virtual networks to create. The map key is an arbitrary value t
114117
- `routing_address_space` - A list of IPv4 address spaces in CIDR format that are used for routing to this hub, e.g. `["192.168.0.0","172.16.0.0/12"]`.
115118
- `hub_router_ip_address` - If not using Azure Firewall, this is the IP address of the hub router. This is used to create route table entries for other hub networks.
116119
- `tags` - A map of tags to apply to the virtual network.
120+
- `route_table_name` - The name of the route table to create for this hub network.
121+
- `route_table_tags` - A map of tags to apply to all route tables.
117122
118123
#### Route table entries
119124
@@ -157,20 +162,22 @@ A map of the hub virtual networks to create. The map key is an arbitrary value t
157162
- `name` - (Optional) The name of the firewall resource. If not specified will use `afw-{vnetname}`.
158163
- `private_ip_ranges` - (Optional) A list of private IP ranges to use for the Azure Firewall, to which the firewall will not NAT traffic. If not specified will use RFC1918.
159164
- `subnet_route_table_id` = (Optional) The resource id of the Route Table which should be associated with the Azure Firewall subnet. If not specified the module will assign the generated route table.
160-
- `tags` - (Optional) A map of tags to apply to the Azure Firewall. If not specified
165+
- `tags` - (Optional) A map of tags to apply to the Azure Firewall.
161166
- `threat_intel_mode` - (Optional) The threat intelligence mode for the Azure Firewall. Possible values include `Alert`, `Deny`, `Off`.
162167
- `zones` - (Optional) A list of availability zones to use for the Azure Firewall. If not specified will be `null`.
163168
- `default_ip_configuration` - (Optional) An object with the following fields. If not specified the defaults below will be used:
164169
- `name` - (Optional) The name of the default IP configuration. If not specified will use `default`.
165170
- `public_ip_config` - (Optional) An object with the following fields:
166171
- `name` - (Optional) The name of the public IP configuration. If not specified will use `pip-afw-{vnetname}`.
172+
- `tags` - (Optional) A map of tags to apply to the public IP configuration.
167173
- `zones` - (Optional) A list of availability zones to use for the public IP configuration. If not specified will be `null`.
168174
- `ip_version` - (Optional) The IP version to use for the public IP configuration. Possible values include `IPv4`, `IPv6`. If not specified will be `IPv4`.
169175
- `sku_tier` - (Optional) The SKU tier to use for the public IP configuration. Possible values include `Regional`, `Global`. If not specified will be `Regional`.
170176
- `management_ip_configuration` - (Optional) An object with the following fields. If not specified the defaults below will be used:
171177
- `name` - (Optional) The name of the management IP configuration. If not specified will use `defaultMgmt`.
172178
- `public_ip_config` - (Optional) An object with the following fields:
173179
- `name` - (Optional) The name of the public IP configuration. If not specified will use `pip-afw-mgmt-<Map Key>`.
180+
- `tags` - (Optional) A map of tags to apply to the public IP configuration.
174181
- `zones` - (Optional) A list of availability zones to use for the public IP configuration. If not specified will be `null`.
175182
- `ip_version` - (Optional) The IP version to use for the public IP configuration. Possible values include `IPv4`, `IPv6`. If not specified will be `IPv4`.
176183
- `sku_tier` - (Optional) The SKU tier to use for the public IP configuration. Possible values include `Regional`, `Global`. If not specified will be `Regional`.

0 commit comments

Comments
 (0)