diff --git a/README.md b/README.md index 97d959771..85dd5c3a0 100644 --- a/README.md +++ b/README.md @@ -536,6 +536,7 @@ No modules. | [private\_subnet\_suffix](#input\_private\_subnet\_suffix) | Suffix to append to private subnets name | `string` | `"private"` | no | | [private\_subnet\_tags](#input\_private\_subnet\_tags) | Additional tags for the private subnets | `map(string)` | `{}` | no | | [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 | +| [private\_subnet\_tags\_per\_name](#input\_private\_subnet\_tags\_per\_name) | Additional tags for the private subnets where the primary key is the subnet name | `map(map(string))` | `{}` | no | | [private\_subnets](#input\_private\_subnets) | A list of private subnets inside the VPC | `list(string)` | `[]` | no | | [propagate\_intra\_route\_tables\_vgw](#input\_propagate\_intra\_route\_tables\_vgw) | Should be true if you want route table propagation | `bool` | `false` | no | | [propagate\_private\_route\_tables\_vgw](#input\_propagate\_private\_route\_tables\_vgw) | Should be true if you want route table propagation | `bool` | `false` | no | @@ -556,6 +557,7 @@ No modules. | [public\_subnet\_suffix](#input\_public\_subnet\_suffix) | Suffix to append to public subnets name | `string` | `"public"` | no | | [public\_subnet\_tags](#input\_public\_subnet\_tags) | Additional tags for the public subnets | `map(string)` | `{}` | no | | [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 | +| [public\_subnet\_tags\_per\_name](#input\_public\_subnet\_tags\_per\_name) | Additional tags for the public subnets where the primary key is the subnet name | `map(map(string))` | `{}` | no | | [public\_subnets](#input\_public\_subnets) | A list of public subnets inside the VPC | `list(string)` | `[]` | no | | [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 | | [redshift\_acl\_tags](#input\_redshift\_acl\_tags) | Additional tags for the redshift subnets network ACL | `map(string)` | `{}` | no | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 579a47395..7566aa8da 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -37,6 +37,14 @@ module "vpc" { intra_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 20)] private_subnet_names = ["Private Subnet One", "Private Subnet Two"] + private_subnet_tags_per_name = { + "Private Subnet One" = { + "subnet one" = "true" + }, + "Private Subnet Two" = { + "subnet two" = "true" + } + } # public_subnet_names omitted to show default name generation for all three subnets database_subnet_names = ["DB Subnet One"] elasticache_subnet_names = ["Elasticache Subnet One", "Elasticache Subnet Two"] diff --git a/main.tf b/main.tf index 77cba6715..2b7cba5c5 100644 --- a/main.tf +++ b/main.tf @@ -120,7 +120,8 @@ resource "aws_subnet" "public" { }, var.tags, var.public_subnet_tags, - lookup(var.public_subnet_tags_per_az, element(var.azs, count.index), {}) + lookup(var.public_subnet_tags_per_az, element(var.azs, count.index), {}), + lookup(var.public_subnet_tags_per_name, try(var.public_subnet_names[count.index], ""), {}) ) } @@ -255,7 +256,8 @@ resource "aws_subnet" "private" { }, var.tags, var.private_subnet_tags, - lookup(var.private_subnet_tags_per_az, element(var.azs, count.index), {}) + lookup(var.private_subnet_tags_per_az, element(var.azs, count.index), {}), + lookup(var.private_subnet_tags_per_name, try(var.private_subnet_names[count.index], ""), {}) ) } diff --git a/variables.tf b/variables.tf index 095cc8bdf..1b1f42e88 100644 --- a/variables.tf +++ b/variables.tf @@ -256,6 +256,12 @@ variable "public_subnet_tags_per_az" { default = {} } +variable "public_subnet_tags_per_name" { + description = "Additional tags for the public subnets where the primary key is the subnet name" + type = map(map(string)) + default = {} +} + variable "public_route_table_tags" { description = "Additional tags for the public route tables" type = map(string) @@ -390,6 +396,12 @@ variable "private_subnet_tags_per_az" { default = {} } +variable "private_subnet_tags_per_name" { + description = "Additional tags for the private subnets where the primary key is the subnet name" + type = map(map(string)) + default = {} +} + variable "private_route_table_tags" { description = "Additional tags for the private route tables" type = map(string)