Skip to content

Commit 8c62508

Browse files
committed
chore(nat-gateway): Add nat_gateway_tags_per_az variable for NAT gateways
1 parent 573f574 commit 8c62508

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ No modules.
502502
| <a name="input_nat_eip_tags"></a> [nat\_eip\_tags](#input\_nat\_eip\_tags) | Additional tags for the NAT EIP | `map(string)` | `{}` | no |
503503
| <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 |
504504
| <a name="input_nat_gateway_tags"></a> [nat\_gateway\_tags](#input\_nat\_gateway\_tags) | Additional tags for the NAT gateways | `map(string)` | `{}` | no |
505+
| <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 |
505506
| <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 |
506507
| <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 |
507508
| <a name="input_outpost_arn"></a> [outpost\_arn](#input\_outpost\_arn) | ARN of Outpost you want to create a subnet in | `string` | `null` | no |

examples/simple/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ module "vpc" {
3232
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 4, k)]
3333

3434
tags = local.tags
35+
36+
nat_gateway_tags_per_az = {
37+
for az in local.azs : az => {
38+
Name = "NAT Gateway - ${az}"
39+
}
40+
}
3541
}

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ resource "aws_nat_gateway" "this" {
10961096
},
10971097
var.tags,
10981098
var.nat_gateway_tags,
1099+
lookup(var.nat_gateway_tags_per_az, element(var.azs, count.index), {})
10991100
)
11001101

11011102
depends_on = [aws_internet_gateway.this]

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,12 @@ variable "nat_gateway_tags" {
12401240
default = {}
12411241
}
12421242

1243+
variable "nat_gateway_tags_per_az" {
1244+
description = "Additional tags for the NAT gateways where the primary key is the AZ"
1245+
type = map(map(string))
1246+
default = {}
1247+
}
1248+
12431249
variable "nat_eip_tags" {
12441250
description = "Additional tags for the NAT EIP"
12451251
type = map(string)

0 commit comments

Comments
 (0)