Skip to content

Commit 4ba8cee

Browse files
feat: Add per AZ tags support for NAT Gateway, NAT EIP and private route table
1 parent 0eefe64 commit 4ba8cee

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,10 @@ No modules.
503503
| <a name="input_map_public_ip_on_launch"></a> [map\_public\_ip\_on\_launch](#input\_map\_public\_ip\_on\_launch) | Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is `false` | `bool` | `false` | no |
504504
| <a name="input_name"></a> [name](#input\_name) | Name to be used on all the resources as identifier | `string` | `""` | no |
505505
| <a name="input_nat_eip_tags"></a> [nat\_eip\_tags](#input\_nat\_eip\_tags) | Additional tags for the NAT EIP | `map(string)` | `{}` | no |
506+
| <a name="input_nat_eip_tags_per_az"></a> [nat\_eip\_tags\_per\_az](#input\_nat\_eip\_tags\_per\_az) | Additional tags for the NAT EIP where the primary key is the AZ | `map(map(string))` | `{}` | no |
506507
| <a name="input_nat_gateway_destination_cidr_block"></a> [nat\_gateway\_destination\_cidr\_block](#input\_nat\_gateway\_destination\_cidr\_block) | Used to pass a custom destination route for private NAT Gateway. If not specified, the default 0.0.0.0/0 is used as a destination route | `string` | `"0.0.0.0/0"` | no |
507508
| <a name="input_nat_gateway_tags"></a> [nat\_gateway\_tags](#input\_nat\_gateway\_tags) | Additional tags for the NAT gateways | `map(string)` | `{}` | no |
509+
| <a name="input_nat_gateway_tags_per_az"></a> [nat\_gateway\_tags\_per\_az](#input\_nat\_gateway\_tags\_per\_az) | Additional tags for the NAT gateways where the primary key is the AZ | `map(map(string))` | `{}` | no |
508510
| <a name="input_one_nat_gateway_per_az"></a> [one\_nat\_gateway\_per\_az](#input\_one\_nat\_gateway\_per\_az) | Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs` | `bool` | `false` | no |
509511
| <a name="input_outpost_acl_tags"></a> [outpost\_acl\_tags](#input\_outpost\_acl\_tags) | Additional tags for the outpost subnets network ACL | `map(string)` | `{}` | no |
510512
| <a name="input_outpost_arn"></a> [outpost\_arn](#input\_outpost\_arn) | ARN of Outpost you want to create a subnet in | `string` | `null` | no |
@@ -528,6 +530,7 @@ No modules.
528530
| <a name="input_private_inbound_acl_rules"></a> [private\_inbound\_acl\_rules](#input\_private\_inbound\_acl\_rules) | Private subnets inbound network ACLs | `list(map(string))` | <pre>[<br/> {<br/> "cidr_block": "0.0.0.0/0",<br/> "from_port": 0,<br/> "protocol": "-1",<br/> "rule_action": "allow",<br/> "rule_number": 100,<br/> "to_port": 0<br/> }<br/>]</pre> | no |
529531
| <a name="input_private_outbound_acl_rules"></a> [private\_outbound\_acl\_rules](#input\_private\_outbound\_acl\_rules) | Private subnets outbound network ACLs | `list(map(string))` | <pre>[<br/> {<br/> "cidr_block": "0.0.0.0/0",<br/> "from_port": 0,<br/> "protocol": "-1",<br/> "rule_action": "allow",<br/> "rule_number": 100,<br/> "to_port": 0<br/> }<br/>]</pre> | no |
530532
| <a name="input_private_route_table_tags"></a> [private\_route\_table\_tags](#input\_private\_route\_table\_tags) | Additional tags for the private route tables | `map(string)` | `{}` | no |
533+
| <a name="input_private_route_table_tags_per_az"></a> [private\_route\_table\_tags\_per\_az](#input\_private\_route\_table\_tags\_per\_az) | Additional tags for the private route tables where the primary key is the AZ | `map(map(string))` | `{}` | no |
531534
| <a name="input_private_subnet_assign_ipv6_address_on_creation"></a> [private\_subnet\_assign\_ipv6\_address\_on\_creation](#input\_private\_subnet\_assign\_ipv6\_address\_on\_creation) | Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is `false` | `bool` | `false` | no |
532535
| <a name="input_private_subnet_enable_dns64"></a> [private\_subnet\_enable\_dns64](#input\_private\_subnet\_enable\_dns64) | Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. Default: `true` | `bool` | `true` | no |
533536
| <a name="input_private_subnet_enable_resource_name_dns_a_record_on_launch"></a> [private\_subnet\_enable\_resource\_name\_dns\_a\_record\_on\_launch](#input\_private\_subnet\_enable\_resource\_name\_dns\_a\_record\_on\_launch) | Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: `false` | `bool` | `false` | no |

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ resource "aws_route_table" "private" {
307307
},
308308
var.tags,
309309
var.private_route_table_tags,
310+
lookup(var.private_route_table_tags_per_az, element(var.azs, count.index), {})
310311
)
311312
}
312313

@@ -1103,6 +1104,7 @@ resource "aws_eip" "nat" {
11031104
},
11041105
var.tags,
11051106
var.nat_eip_tags,
1107+
lookup(var.nat_eip_tags_per_az, element(var.azs, count.index), {})
11061108
)
11071109

11081110
depends_on = [aws_internet_gateway.this]
@@ -1129,6 +1131,7 @@ resource "aws_nat_gateway" "this" {
11291131
},
11301132
var.tags,
11311133
var.nat_gateway_tags,
1134+
lookup(var.nat_gateway_tags_per_az, element(var.azs, count.index), {})
11321135
)
11331136

11341137
depends_on = [aws_internet_gateway.this]

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,12 @@ variable "private_route_table_tags" {
408408
default = {}
409409
}
410410

411+
variable "private_route_table_tags_per_az" {
412+
description = "Additional tags for the private route tables where the primary key is the AZ"
413+
type = map(map(string))
414+
default = {}
415+
}
416+
411417
################################################################################
412418
# Private Network ACLs
413419
################################################################################
@@ -1252,12 +1258,24 @@ variable "nat_gateway_tags" {
12521258
default = {}
12531259
}
12541260

1261+
variable "nat_gateway_tags_per_az" {
1262+
description = "Additional tags for the NAT gateways where the primary key is the AZ"
1263+
type = map(map(string))
1264+
default = {}
1265+
}
1266+
12551267
variable "nat_eip_tags" {
12561268
description = "Additional tags for the NAT EIP"
12571269
type = map(string)
12581270
default = {}
12591271
}
12601272

1273+
variable "nat_eip_tags_per_az" {
1274+
description = "Additional tags for the NAT EIP where the primary key is the AZ"
1275+
type = map(map(string))
1276+
default = {}
1277+
}
1278+
12611279
################################################################################
12621280
# Customer Gateways
12631281
################################################################################

0 commit comments

Comments
 (0)