Skip to content

Commit

Permalink
feat: Add public and private and database tags per cidr
Browse files Browse the repository at this point in the history
  • Loading branch information
kahirokunn committed Mar 6, 2023
1 parent 995217b commit e3a56b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,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_cidr, element(concat(var.public_subnets, [""]), count.index), {})
)
}

Expand Down Expand Up @@ -405,7 +406,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_cidr, var.private_subnets[count.index], {})
)
}

Expand Down Expand Up @@ -461,7 +463,8 @@ resource "aws_subnet" "database" {
},
var.tags,
var.database_subnet_tags,
lookup(var.database_subnet_tags_per_az, element(var.azs, count.index), {})
lookup(var.database_subnet_tags_per_az, element(var.azs, count.index), {}),
lookup(var.database_subnet_tags_per_cidr, var.database_subnets[count.index])
)
}

Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ variable "public_subnet_tags_per_az" {
default = {}
}

variable "public_subnet_tags_per_cidr" {
description = "Additional tags for the public subnets where the primary key is the CIDR"
type = map(map(string))
default = {}
}

variable "private_subnet_tags" {
description = "Additional tags for the private subnets"
type = map(string)
Expand All @@ -504,6 +510,12 @@ variable "private_subnet_tags_per_az" {
default = {}
}

variable "private_subnet_tags_per_cidr" {
description = "Additional tags for the private subnets where the primary key is the CIDR"
type = map(map(string))
default = {}
}

variable "outpost_subnet_tags" {
description = "Additional tags for the outpost subnets"
type = map(string)
Expand Down Expand Up @@ -564,6 +576,12 @@ variable "database_subnet_tags_per_az" {
default = {}
}

variable "database_subnet_tags_per_cidr" {
description = "Additional tags for the database subnets where the primary key is the CIDR"
type = map(map(string))
default = {}
}

variable "database_subnet_group_tags" {
description = "Additional tags for the database subnet group"
type = map(string)
Expand Down

0 comments on commit e3a56b8

Please sign in to comment.