Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "intra subnets" as a class #135

Merged
merged 4 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 20 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ resource "aws_elasticache_subnet_group" "elasticache" {
subnet_ids = ["${aws_subnet.elasticache.*.id}"]
}

#####################################################
# infra subnets - private subnet with no NAT gateway
#####################################################
resource "aws_subnet" "infra" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be intra, not infra

count = "${var.create_vpc && length(var.infra_subnets) > 0 ? length(var.infra_subnets) : 0}"

vpc_id = "${aws_vpc.this.id}"
cidr_block = "${var.infra_subnets[count.index]}"
availability_zone = "${element(var.azs, count.index)}"

tags = "${merge(var.tags, var.infra_subnet_tags, map("Name", format("%s-infra-%s", var.name, element(var.azs, count.index))))}"
}

##############
# NAT Gateway
##############
Expand Down Expand Up @@ -329,6 +342,13 @@ resource "aws_route_table_association" "elasticache" {
route_table_id = "${element(aws_route_table.private.*.id, (var.single_nat_gateway ? 0 : count.index))}"
}

resource "aws_route_table_association" "infra" {
count = "${var.create_vpc && length(var.infra_subnets) > 0 ? length(var.infra_subnets) : 0}"

subnet_id = "${element(aws_subnet.infra.*.id, count.index)}"
route_table_id = "${element(aws_route_table.private.*.id, (var.single_nat_gateway ? 0 : count.index))}"
}

resource "aws_route_table_association" "public" {
count = "${var.create_vpc && length(var.public_subnets) > 0 ? length(var.public_subnets) : 0}"

Expand Down
10 changes: 10 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ output "elasticache_subnets_cidr_blocks" {
value = ["${aws_subnet.elasticache.*.cidr_block}"]
}

output "infra_subnets" {
description = "List of IDs of infra subnets"
value = ["${aws_subnet.infra.*.id}"]
}

output "infra_subnets_cidr_blocks" {
description = "List of cidr_blocks of infra subnets"
value = ["${aws_subnet.infra.*.cidr_block}"]
}

output "elasticache_subnet_group" {
description = "ID of elasticache subnet group"
value = "${element(concat(aws_elasticache_subnet_group.elasticache.*.id, list("")), 0)}"
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ variable "elasticache_subnets" {
default = []
}

variable "infra_subnets" {
type = "list"
description = "A list of infra subnets"
default = []
}

variable "create_database_subnet_group" {
description = "Controls if database subnet group should be created"
default = true
Expand Down Expand Up @@ -177,6 +183,11 @@ variable "elasticache_subnet_tags" {
default = {}
}

variable "infra_subnet_tags" {
description = "Additional tags for the infra subnets"
default = {}
}

variable "dhcp_options_tags" {
description = "Additional tags for the DHCP option set"
default = {}
Expand Down