Skip to content

Commit 9f2a4d3

Browse files
author
Radon Rosborough
committed
feat: Allow tagging on per-subnet basis
1 parent 33b09ca commit 9f2a4d3

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ No modules.
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 |
498498
| <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 |
499+
| <a name="input_private_subnet_tags_per_subnet"></a> [private\_subnet\_tags\_per\_subnet](#input\_private\_subnet\_tags\_per\_subnet) | Additional tags for the private subnets, if specified then must have a length equal to the number of private subnets | `list(map(string))` | `[]` | no |
499500
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | A list of private subnets inside the VPC | `list(string)` | `[]` | no |
500501
| <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 |
501502
| <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 |
@@ -511,6 +512,7 @@ No modules.
511512
| <a name="input_public_subnet_suffix"></a> [public\_subnet\_suffix](#input\_public\_subnet\_suffix) | Suffix to append to public subnets name | `string` | `"public"` | no |
512513
| <a name="input_public_subnet_tags"></a> [public\_subnet\_tags](#input\_public\_subnet\_tags) | Additional tags for the public subnets | `map(string)` | `{}` | no |
513514
| <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 |
515+
| <a name="input_public_subnet_tags_per_subnet"></a> [public\_subnet\_tags\_per\_subnet](#input\_public\_subnet\_tags\_per\_subnet) | Additional tags for the public subnets, if specified then must have a length equal to the number of public subnets | `list(map(string))` | `[]` | no |
514516
| <a name="input_public_subnets"></a> [public\_subnets](#input\_public\_subnets) | A list of public subnets inside the VPC | `list(string)` | `[]` | no |
515517
| <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 |
516518
| <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 |

main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ 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), {})
380+
lookup(var.public_subnet_tags_per_az, element(var.azs, count.index), {}),
381+
length(var.public_subnet_tags_per_subnet) > 0 ? element(var.public_subnet_tags_per_subnet, count.index) : {},
381382
)
382383
}
383384

@@ -405,7 +406,8 @@ resource "aws_subnet" "private" {
405406
},
406407
var.tags,
407408
var.private_subnet_tags,
408-
lookup(var.private_subnet_tags_per_az, element(var.azs, count.index), {})
409+
lookup(var.private_subnet_tags_per_az, element(var.azs, count.index), {}),
410+
length(var.private_subnet_tags_per_subnet) > 0 ? element(var.private_subnet_tags_per_subnet, count.index) : {},
409411
)
410412
}
411413

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,12 @@ variable "public_subnet_tags_per_az" {
492492
default = {}
493493
}
494494

495+
variable "public_subnet_tags_per_subnet" {
496+
description = "Additional tags for the public subnets, if specified then must have a length equal to the number of public subnets"
497+
type = list(map(string))
498+
default = []
499+
}
500+
495501
variable "private_subnet_tags" {
496502
description = "Additional tags for the private subnets"
497503
type = map(string)
@@ -504,6 +510,12 @@ variable "private_subnet_tags_per_az" {
504510
default = {}
505511
}
506512

513+
variable "private_subnet_tags_per_subnet" {
514+
description = "Additional tags for the private subnets, if specified then must have a length equal to the number of private subnets"
515+
type = list(map(string))
516+
default = []
517+
}
518+
507519
variable "outpost_subnet_tags" {
508520
description = "Additional tags for the outpost subnets"
509521
type = map(string)

0 commit comments

Comments
 (0)