Skip to content

Commit

Permalink
Fix tags to use output of label module (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
GabeL7r authored and aknysh committed Oct 5, 2018
1 parent 7503f54 commit 6184f62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
7 changes: 2 additions & 5 deletions private.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module "private_subnet_label" {
stage = "${var.stage}"
name = "subnet"
attributes = ["private"]
tags = "${var.tags}"
}

locals {
Expand All @@ -26,11 +27,7 @@ resource "aws_subnet" "private" {
availability_zone = "${element(var.availability_zones, count.index)}"
cidr_block = "${cidrsubnet(signum(length(var.cidr_block)) == 1 ? var.cidr_block : data.aws_vpc.default.cidr_block, ceil(log(local.private_subnet_count * 2, 2)), count.index)}"

tags = {
"Name" = "${module.private_subnet_label.id}${var.delimiter}${replace(element(var.availability_zones, count.index),"-",var.delimiter)}"
"Stage" = "${module.private_subnet_label.stage}"
"Namespace" = "${module.private_subnet_label.namespace}"
}
tags = "${merge(module.private_subnet_label.tags, map("Name",format("%s%s%s", module.private_subnet_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}"
}

resource "aws_route_table" "private" {
Expand Down
13 changes: 5 additions & 8 deletions public.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module "public_subnet_label" {
module "public_label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3"
namespace = "${var.namespace}"
stage = "${var.stage}"
name = "${var.name}"
delimiter = "${var.delimiter}"
attributes = ["public"]
tags = "${var.tags}"
}

module "public_label" {
module "public_subnet_label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.3"
namespace = "${var.namespace}"
stage = "${var.stage}"
name = "${var.name}"
delimiter = "${var.delimiter}"
attributes = ["public"]
tags = "${var.tags}"
}
Expand All @@ -26,11 +27,7 @@ resource "aws_subnet" "public" {
availability_zone = "${element(var.availability_zones, count.index)}"
cidr_block = "${cidrsubnet(signum(length(var.cidr_block)) == 1 ? var.cidr_block : data.aws_vpc.default.cidr_block, ceil(log(local.public_subnet_count * 2, 2)), local.public_subnet_count + count.index)}"

tags = {
"Name" = "${module.public_subnet_label.id}${var.delimiter}${replace(element(var.availability_zones, count.index),"-",var.delimiter)}"
"Stage" = "${module.public_subnet_label.stage}"
"Namespace" = "${module.public_subnet_label.namespace}"
}
tags = "${merge(module.public_subnet_label.tags, map("Name",format("%s%s%s", module.public_subnet_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}"
}

resource "aws_route_table" "public" {
Expand Down

0 comments on commit 6184f62

Please sign in to comment.