From f7cb6f8e64959e647f03eb5cff740f02255ecc41 Mon Sep 17 00:00:00 2001 From: Jan Sebastian Siwy Date: Mon, 23 Sep 2024 18:19:51 +0200 Subject: [PATCH 1/3] Add support for resource-specific tags --- availability-zone/main.tf | 24 ++++++-- availability-zone/variables.tf | 54 +++++++++++++++++ main.tf | 29 +++++++-- variables.tf | 108 +++++++++++++++++++++++++++++++++ 4 files changed, 203 insertions(+), 12 deletions(-) diff --git a/availability-zone/main.tf b/availability-zone/main.tf index 35f5069..62fd213 100644 --- a/availability-zone/main.tf +++ b/availability-zone/main.tf @@ -9,7 +9,9 @@ locals { resource "aws_route_table" "public" { vpc_id = var.vpc.id - tags = merge({ Name = "public - ${local.availability_zone}" }, var.default_tags) + tags = merge({ + Name = "public - ${local.availability_zone}" + }, var.default_tags, var.public_route_table_tags) } resource "aws_route" "internet_gateway" { @@ -25,7 +27,9 @@ resource "aws_subnet" "public" { availability_zone = local.availability_zone map_public_ip_on_launch = true - tags = merge({ Name = "public - ${local.availability_zone}" }, var.default_tags) + tags = merge({ + Name = "public - ${local.availability_zone}" + }, var.default_tags, var.public_subnet_tags) } resource "aws_route_table_association" "public" { @@ -38,14 +42,18 @@ resource "aws_route_table_association" "public" { resource "aws_eip" "this" { domain = "vpc" - tags = merge({ Name = local.availability_zone }, var.default_tags) + tags = merge({ + Name = local.availability_zone + }, var.default_tags, var.nat_gateway_eip_tags) } resource "aws_nat_gateway" "this" { subnet_id = aws_subnet.public.id allocation_id = aws_eip.this.id - tags = merge({ Name = local.availability_zone }, var.default_tags) + tags = merge({ + Name = local.availability_zone + }, var.default_tags, var.nat_gateway_tags) } # Private Subnet @@ -53,7 +61,9 @@ resource "aws_nat_gateway" "this" { resource "aws_route_table" "private" { vpc_id = var.vpc.id - tags = merge({ Name = "private - ${local.availability_zone}" }, var.default_tags) + tags = merge({ + Name = "private - ${local.availability_zone}" + }, var.default_tags, var.private_route_table_tags) } resource "aws_route" "nat_gateway" { @@ -69,7 +79,9 @@ resource "aws_subnet" "private" { availability_zone = local.availability_zone map_public_ip_on_launch = false - tags = merge({ Name = "private - ${local.availability_zone}" }, var.default_tags) + tags = merge({ + Name = "private - ${local.availability_zone}" + }, var.default_tags, var.private_subnet_tags) } resource "aws_route_table_association" "private" { diff --git a/availability-zone/variables.tf b/availability-zone/variables.tf index 6119c51..49de713 100644 --- a/availability-zone/variables.tf +++ b/availability-zone/variables.tf @@ -17,6 +17,60 @@ Internet Gateway which belongs to `var.vpc`. EOS } +variable "nat_gateway_eip_tags" { + type = map(string) + default = {} + + description = < Date: Mon, 23 Sep 2024 18:29:53 +0200 Subject: [PATCH 2/3] unify tags --- availability-zone/variables.tf | 12 ++++++------ variables.tf | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/availability-zone/variables.tf b/availability-zone/variables.tf index 49de713..05be684 100644 --- a/availability-zone/variables.tf +++ b/availability-zone/variables.tf @@ -22,7 +22,7 @@ variable "nat_gateway_eip_tags" { default = {} description = < Date: Mon, 23 Sep 2024 18:34:28 +0200 Subject: [PATCH 3/3] Update variables.tf --- variables.tf | 54 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/variables.tf b/variables.tf index e38c0ca..f33599e 100644 --- a/variables.tf +++ b/variables.tf @@ -42,6 +42,33 @@ Map of tags assigned to all AWS resources created by this module. EOS } +variable "gateway_vpc_endpoint_tags" { + type = map(string) + default = {} + + description = <