Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for resource-specific tags #27

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module "subnets" {
availability_zone = each.key
cidr_block = each.value

route_table_tags = var.route_table_tags
subnet_tags = var.subnet_tags

default_tags = var.default_tags
}

Expand All @@ -23,7 +26,7 @@ resource "aws_lb" "this" {
internal = true
subnets = values(module.subnets)[*].this.id

tags = var.default_tags
tags = merge(var.default_tags, var.lb_tags)
}

# API Gateway VPC Link
Expand All @@ -32,5 +35,5 @@ resource "aws_api_gateway_vpc_link" "this" {
name = var.name
target_arns = [aws_lb.this.arn]

tags = var.default_tags
tags = merge(var.default_tags, var.api_gateway_vpc_link_tags)
}
4 changes: 2 additions & 2 deletions subnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ resource "aws_subnet" "this" {

tags = merge({
Name = "private - ${var.name} - ${var.availability_zone}"
}, var.default_tags)
}, var.default_tags, var.subnet_tags)
}

resource "aws_route_table" "this" {
vpc_id = var.vpc.id

tags = merge({
Name = "private - ${var.name} - ${var.availability_zone}"
}, var.default_tags)
}, var.default_tags, var.route_table_tags)
}

resource "aws_route_table_association" "this" {
Expand Down
18 changes: 18 additions & 0 deletions subnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ Name of the NLB.
EOS
}

variable "route_table_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the route table created by this module. Tags in this map will override tags in `var.default_tags`.
EOS
}

variable "subnet_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the subnet created by this module. Tags in this map will override tags in `var.default_tags`.
EOS
}

variable "vpc" {
type = object({
id = string
Expand Down
36 changes: 36 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
variable "api_gateway_vpc_link_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the API Gateway VPC Link created by this module. Tags in this map will override tags in `var.default_tags`.
EOS
}

variable "cidr_blocks" {
type = map(string)

Expand All @@ -15,6 +24,15 @@ Map of tags assigned to all AWS resources created by this module.
EOS
}

variable "lb_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the NLB created by this module. Tags in this map will override tags in `var.default_tags`.
EOS
}

variable "name" {
type = string

Expand All @@ -23,6 +41,24 @@ Name of the NLB.
EOS
}

variable "route_table_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the route tables created by this module. Tags in this map will override tags in `var.default_tags`.
EOS
}

variable "subnet_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the subnets created by this module. Tags in this map will override tags in `var.default_tags`.
EOS
}

variable "vpc" {
type = object({
id = string
Expand Down