From 8bfd7d595b48d6d54bb1c97696fcee8bbeefebd8 Mon Sep 17 00:00:00 2001 From: Cristobal Villarroel Date: Thu, 22 Jul 2021 08:26:44 -0700 Subject: [PATCH] Allow subnet specific tags This commit allows the use of tags that are specific to the dmz and tags that are specific to the lan. --- az/main.tf | 4 ++-- az/variables.tf | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/az/main.tf b/az/main.tf index 93a1ed3..2378783 100644 --- a/az/main.tf +++ b/az/main.tf @@ -67,7 +67,7 @@ resource "aws_subnet" "dmz" { map_public_ip_on_launch = "${var.enable_dmz_public_ips}" vpc_id = "${var.vpc_id}" - tags = "${merge(local.default_subnet_tags, var.additional_subnet_tags, map("Name", "${var.stack_item_label}-dmz-${count.index}"))}" + tags = "${merge(local.default_subnet_tags, var.additional_dmz_tags, var.additional_subnet_tags, map("Name", "${var.stack_item_label}-dmz-${count.index}"))}" } ### Associates subnet with routing table @@ -188,7 +188,7 @@ resource "aws_subnet" "lan" { cidr_block = "${local.lan_cidrs_override_enabled == "true" ? element(var.lan_cidrs_override,count.index) : cidrsubnet(data.aws_vpc.base.cidr_block,lookup(var.az_cidrsubnet_newbits, local.azs_provisioned_count * local.lans_multiplier),count.index + lookup(var.az_cidrsubnet_offset, local.azs_provisioned_count))}" vpc_id = "${var.vpc_id}" - tags = "${merge(local.default_subnet_tags, var.additional_subnet_tags, map("Name", "${var.stack_item_label}-lan-${count.index}"))}" + tags = "${merge(local.default_subnet_tags, var.additional_lan_tags, var.additional_subnet_tags, map("Name", "${var.stack_item_label}-lan-${count.index}"))}" } ### Provisions routing table diff --git a/az/variables.tf b/az/variables.tf index 967a4ad..8ad20ef 100644 --- a/az/variables.tf +++ b/az/variables.tf @@ -13,6 +13,18 @@ variable "stack_item_label" { default = "qckstrt" } +variable "additional_dmz_tags" { + type = "map" + description = "Additional tags to apply at the dmz subnet level, if any" + default = {} +} + +variable "additional_lan_tags" { + type = "map" + description = "Additional tags to apply at the lan subnet level, if any" + default = {} +} + variable "additional_subnet_tags" { type = "map" description = "Additional tags to apply at the subnet level, if any"