Skip to content
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
4 changes: 2 additions & 2 deletions nat.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ locals {
resource "aws_eip" "default" {
count = "${local.nat_gateways_count}"
vpc = true
tags = "${module.private_label.tags}"
tags = "${merge(module.private_label.tags, map("Name",format("%s%s%s", module.private_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}"

lifecycle {
create_before_destroy = true
Expand All @@ -26,7 +26,7 @@ resource "aws_nat_gateway" "default" {
count = "${local.nat_gateways_count}"
allocation_id = "${element(aws_eip.default.*.id, count.index)}"
subnet_id = "${element(aws_subnet.public.*.id, count.index)}"
tags = "${module.nat_label.tags}"
tags = "${merge(module.nat_label.tags, map("Name",format("%s%s%s", module.nat_label.id, var.delimiter, replace(element(var.availability_zones, count.index),"-",var.delimiter))))}"

lifecycle {
create_before_destroy = true
Expand Down
10 changes: 10 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ output "private_route_table_ids" {
description = "AWS IDs of the created private route tables"
value = ["${aws_route_table.private.*.id}"]
}

output "nat_gateway_ids" {
description = "AWS IDs of the NAT gateways created"
value = ["${aws_nat_gateway.default.*.id}"]
}

output "availability_zones" {
description = "List of Availability Zones where subnets were created"
value = "${var.availability_zones}"
}
7 changes: 6 additions & 1 deletion private.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ resource "aws_subnet" "private" {
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 = "${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))))}"

lifecycle {
# Ignore tags added by kops or kubernetes
ignore_changes = ["tags.%", "tags.kubernetes", "tags.SubnetType"]
}
}

resource "aws_route_table" "private" {
count = "${length(var.availability_zones)}"
vpc_id = "${data.aws_vpc.default.id}"

tags = "${module.private_label.tags}"
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_association" "private" {
Expand Down
5 changes: 5 additions & 0 deletions public.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ resource "aws_subnet" "public" {
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)}"
map_public_ip_on_launch = "${local.map_public_ip_on_launch}"
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))))}"

lifecycle {
# Ignore tags added by kops or kubernetes
ignore_changes = ["tags.%", "tags.kubernetes", "tags.SubnetType"]
}
}

resource "aws_route_table" "public" {
Expand Down