diff --git a/README.md b/README.md index a84b5f8..2f59888 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,5 @@ module "vpc" { gateway = ["dynamodb", "s3"] interface = ["logs"] } - - tags = { - app = "example" - env = "production" - } } ``` diff --git a/_test/main.tf b/_test/main.tf index 9978d89..8d4e2a8 100644 --- a/_test/main.tf +++ b/_test/main.tf @@ -17,5 +17,5 @@ module "vpc" { tags = { app = "example" env = "production" - } + } } diff --git a/availability-zone/main.tf b/availability-zone/main.tf index 678616d..5349330 100644 --- a/availability-zone/main.tf +++ b/availability-zone/main.tf @@ -9,7 +9,7 @@ locals { resource "aws_route_table" "public" { vpc_id = var.vpc.id - tags = merge({ Name = "public - ${local.availability_zone}" }, var.tags) + tags = merge({ Name = "public - ${local.availability_zone}" }, var.default_tags, var.public_route_table_tags) } resource "aws_route" "internet_gateway" { @@ -25,7 +25,7 @@ resource "aws_subnet" "public" { availability_zone = local.availability_zone map_public_ip_on_launch = true - tags = merge({ Name = "public - ${local.availability_zone}" }, var.tags) + tags = merge({ Name = "public - ${local.availability_zone}" }, var.default_tags, var.public_subnet_tags) } resource "aws_route_table_association" "public" { @@ -38,14 +38,14 @@ resource "aws_route_table_association" "public" { resource "aws_eip" "this" { domain = "vpc" - tags = merge({ Name = local.availability_zone }, var.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.tags) + tags = merge({ Name = local.availability_zone }, var.default_tags, var.nat_gateway_tags) } # Private Subnet @@ -53,7 +53,7 @@ resource "aws_nat_gateway" "this" { resource "aws_route_table" "private" { vpc_id = var.vpc.id - tags = merge({ Name = "private - ${local.availability_zone}" }, var.tags) + tags = merge({ Name = "private - ${local.availability_zone}" }, var.default_tags, var.private_route_table_tags) } resource "aws_route" "nat_gateway" { @@ -69,7 +69,7 @@ resource "aws_subnet" "private" { availability_zone = local.availability_zone map_public_ip_on_launch = false - tags = merge({ Name = "private - ${local.availability_zone}" }, var.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 e93e02f..cd76ae7 100644 --- a/availability-zone/variables.tf +++ b/availability-zone/variables.tf @@ -1,45 +1,106 @@ -variable "internet_gateway" { - description = "Internet Gateway which belongs to `var.vpc`" +variable "default_tags" { + type = map(string) + default = {} + description = <