Skip to content

Commit e3a56b8

Browse files
committed
feat: Add public and private and database tags per cidr
1 parent 995217b commit e3a56b8

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

main.tf

+6-3
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+
lookup(var.public_subnet_tags_per_cidr, element(concat(var.public_subnets, [""]), 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+
lookup(var.private_subnet_tags_per_cidr, var.private_subnets[count.index], {})
409411
)
410412
}
411413

@@ -461,7 +463,8 @@ resource "aws_subnet" "database" {
461463
},
462464
var.tags,
463465
var.database_subnet_tags,
464-
lookup(var.database_subnet_tags_per_az, element(var.azs, count.index), {})
466+
lookup(var.database_subnet_tags_per_az, element(var.azs, count.index), {}),
467+
lookup(var.database_subnet_tags_per_cidr, var.database_subnets[count.index])
465468
)
466469
}
467470

variables.tf

+18
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_cidr" {
496+
description = "Additional tags for the public subnets where the primary key is the CIDR"
497+
type = map(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_cidr" {
514+
description = "Additional tags for the private subnets where the primary key is the CIDR"
515+
type = map(map(string))
516+
default = {}
517+
}
518+
507519
variable "outpost_subnet_tags" {
508520
description = "Additional tags for the outpost subnets"
509521
type = map(string)
@@ -564,6 +576,12 @@ variable "database_subnet_tags_per_az" {
564576
default = {}
565577
}
566578

579+
variable "database_subnet_tags_per_cidr" {
580+
description = "Additional tags for the database subnets where the primary key is the CIDR"
581+
type = map(map(string))
582+
default = {}
583+
}
584+
567585
variable "database_subnet_group_tags" {
568586
description = "Additional tags for the database subnet group"
569587
type = map(string)

0 commit comments

Comments
 (0)