Skip to content

Commit a82c9d3

Browse files
feat: Add public and private tags per az (#860)
Co-authored-by: Anton Babenko <[email protected]>
1 parent 2a0319e commit a82c9d3

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ No modules.
495495
| <a name="input_private_subnet_names"></a> [private\_subnet\_names](#input\_private\_subnet\_names) | Explicit values to use in the Name tag on private subnets. If empty, Name tags are generated. | `list(string)` | `[]` | no |
496496
| <a name="input_private_subnet_suffix"></a> [private\_subnet\_suffix](#input\_private\_subnet\_suffix) | Suffix to append to private subnets name | `string` | `"private"` | no |
497497
| <a name="input_private_subnet_tags"></a> [private\_subnet\_tags](#input\_private\_subnet\_tags) | Additional tags for the private subnets | `map(string)` | `{}` | no |
498+
| <a name="input_private_subnet_tags_per_az"></a> [private\_subnet\_tags\_per\_az](#input\_private\_subnet\_tags\_per\_az) | Additional tags for the private subnets where the primary key is the AZ | `map(map(string))` | `{}` | no |
498499
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | A list of private subnets inside the VPC | `list(string)` | `[]` | no |
499500
| <a name="input_propagate_intra_route_tables_vgw"></a> [propagate\_intra\_route\_tables\_vgw](#input\_propagate\_intra\_route\_tables\_vgw) | Should be true if you want route table propagation | `bool` | `false` | no |
500501
| <a name="input_propagate_private_route_tables_vgw"></a> [propagate\_private\_route\_tables\_vgw](#input\_propagate\_private\_route\_tables\_vgw) | Should be true if you want route table propagation | `bool` | `false` | no |
@@ -509,6 +510,7 @@ No modules.
509510
| <a name="input_public_subnet_names"></a> [public\_subnet\_names](#input\_public\_subnet\_names) | Explicit values to use in the Name tag on public subnets. If empty, Name tags are generated. | `list(string)` | `[]` | no |
510511
| <a name="input_public_subnet_suffix"></a> [public\_subnet\_suffix](#input\_public\_subnet\_suffix) | Suffix to append to public subnets name | `string` | `"public"` | no |
511512
| <a name="input_public_subnet_tags"></a> [public\_subnet\_tags](#input\_public\_subnet\_tags) | Additional tags for the public subnets | `map(string)` | `{}` | no |
513+
| <a name="input_public_subnet_tags_per_az"></a> [public\_subnet\_tags\_per\_az](#input\_public\_subnet\_tags\_per\_az) | Additional tags for the public subnets where the primary key is the AZ | `map(map(string))` | `{}` | no |
512514
| <a name="input_public_subnets"></a> [public\_subnets](#input\_public\_subnets) | A list of public subnets inside the VPC | `list(string)` | `[]` | no |
513515
| <a name="input_putin_khuylo"></a> [putin\_khuylo](#input\_putin\_khuylo) | Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo! | `bool` | `true` | no |
514516
| <a name="input_redshift_acl_tags"></a> [redshift\_acl\_tags](#input\_redshift\_acl\_tags) | Additional tags for the redshift subnets network ACL | `map(string)` | `{}` | no |

examples/simple-vpc/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ module "vpc" {
3636
Name = "overridden-name-public"
3737
}
3838

39+
public_subnet_tags_per_az = {
40+
"${local.region}a" = {
41+
"availability-zone" = "${local.region}a"
42+
}
43+
}
44+
3945
tags = local.tags
4046

4147
vpc_tags = {

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ resource "aws_subnet" "public" {
377377
},
378378
var.tags,
379379
var.public_subnet_tags,
380+
lookup(var.public_subnet_tags_per_az, element(var.azs, count.index), {})
380381
)
381382
}
382383

@@ -404,6 +405,7 @@ resource "aws_subnet" "private" {
404405
},
405406
var.tags,
406407
var.private_subnet_tags,
408+
lookup(var.private_subnet_tags_per_az, element(var.azs, count.index), {})
407409
)
408410
}
409411

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,24 @@ variable "public_subnet_tags" {
486486
default = {}
487487
}
488488

489+
variable "public_subnet_tags_per_az" {
490+
description = "Additional tags for the public subnets where the primary key is the AZ"
491+
type = map(map(string))
492+
default = {}
493+
}
494+
489495
variable "private_subnet_tags" {
490496
description = "Additional tags for the private subnets"
491497
type = map(string)
492498
default = {}
493499
}
494500

501+
variable "private_subnet_tags_per_az" {
502+
description = "Additional tags for the private subnets where the primary key is the AZ"
503+
type = map(map(string))
504+
default = {}
505+
}
506+
495507
variable "outpost_subnet_tags" {
496508
description = "Additional tags for the outpost subnets"
497509
type = map(string)

0 commit comments

Comments
 (0)