Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Enable backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
geidies committed Jul 6, 2018
1 parent f7a874c commit 8edc872
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
terraform.tfstate
terraform.tfvars
Gemfile.lock
.idea
32 changes: 16 additions & 16 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ locals {
######
# VPC
######
resource "aws_vpc" "this" {
resource "aws_vpc" "mod" {
count = "${var.create_vpc ? 1 : 0}"

cidr_block = "${var.cidr}"
Expand Down Expand Up @@ -42,7 +42,7 @@ resource "aws_vpc_dhcp_options" "this" {
resource "aws_vpc_dhcp_options_association" "this" {
count = "${var.create_vpc && var.enable_dhcp_options ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"
dhcp_options_id = "${aws_vpc_dhcp_options.this.id}"
}

Expand All @@ -52,7 +52,7 @@ resource "aws_vpc_dhcp_options_association" "this" {
resource "aws_internet_gateway" "this" {
count = "${var.create_vpc && length(var.public_subnets) > 0 ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"

tags = "${merge(map("Name", format("%s", var.name)), var.igw_tags, var.tags)}"
}
Expand All @@ -63,7 +63,7 @@ resource "aws_internet_gateway" "this" {
resource "aws_route_table" "public" {
count = "${var.create_vpc && length(var.public_subnets) > 0 ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"

tags = "${merge(map("Name", format("%s-public", var.name)), var.public_route_table_tags, var.tags)}"
}
Expand All @@ -87,7 +87,7 @@ resource "aws_route" "public_internet_gateway" {
resource "aws_route_table" "private" {
count = "${var.create_vpc && local.max_subnet_length > 0 ? local.nat_gateway_count : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"

tags = "${merge(map("Name", (var.single_nat_gateway ? "${var.name}-private" : format("%s-private-%s", var.name, element(var.azs, count.index)))), var.private_route_table_tags, var.tags)}"

Expand All @@ -104,7 +104,7 @@ resource "aws_route_table" "private" {
resource "aws_route_table" "intra" {
count = "${var.create_vpc && length(var.intra_subnets) > 0 ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"

tags = "${merge(map("Name", "${var.name}-intra"), var.intra_route_table_tags, var.tags)}"
}
Expand All @@ -115,7 +115,7 @@ resource "aws_route_table" "intra" {
resource "aws_subnet" "public" {
count = "${var.create_vpc && length(var.public_subnets) > 0 && (!var.one_nat_gateway_per_az || length(var.public_subnets) >= length(var.azs)) ? length(var.public_subnets) : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"
cidr_block = "${var.public_subnets[count.index]}"
availability_zone = "${element(var.azs, count.index)}"
map_public_ip_on_launch = "${var.map_public_ip_on_launch}"
Expand All @@ -129,7 +129,7 @@ resource "aws_subnet" "public" {
resource "aws_subnet" "private" {
count = "${var.create_vpc && length(var.private_subnets) > 0 ? length(var.private_subnets) : 0}"

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

Expand All @@ -142,7 +142,7 @@ resource "aws_subnet" "private" {
resource "aws_subnet" "database" {
count = "${var.create_vpc && length(var.database_subnets) > 0 ? length(var.database_subnets) : 0}"

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

Expand All @@ -165,7 +165,7 @@ resource "aws_db_subnet_group" "database" {
resource "aws_subnet" "redshift" {
count = "${var.create_vpc && length(var.redshift_subnets) > 0 ? length(var.redshift_subnets) : 0}"

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

Expand All @@ -188,7 +188,7 @@ resource "aws_redshift_subnet_group" "redshift" {
resource "aws_subnet" "elasticache" {
count = "${var.create_vpc && length(var.elasticache_subnets) > 0 ? length(var.elasticache_subnets) : 0}"

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

Expand All @@ -209,7 +209,7 @@ resource "aws_elasticache_subnet_group" "elasticache" {
resource "aws_subnet" "intra" {
count = "${var.create_vpc && length(var.intra_subnets) > 0 ? length(var.intra_subnets) : 0}"

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

Expand Down Expand Up @@ -274,7 +274,7 @@ data "aws_vpc_endpoint_service" "s3" {
resource "aws_vpc_endpoint" "s3" {
count = "${var.create_vpc && var.enable_s3_endpoint ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"
}

Expand Down Expand Up @@ -311,7 +311,7 @@ data "aws_vpc_endpoint_service" "dynamodb" {
resource "aws_vpc_endpoint" "dynamodb" {
count = "${var.create_vpc && var.enable_dynamodb_endpoint ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"
service_name = "${data.aws_vpc_endpoint_service.dynamodb.service_name}"
}

Expand Down Expand Up @@ -387,15 +387,15 @@ resource "aws_route_table_association" "public" {
resource "aws_vpn_gateway" "this" {
count = "${var.create_vpc && var.enable_vpn_gateway ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"

tags = "${merge(map("Name", format("%s", var.name)), var.vpn_gateway_tags, var.tags)}"
}

resource "aws_vpn_gateway_attachment" "this" {
count = "${var.vpn_gateway_id != "" ? 1 : 0}"

vpc_id = "${aws_vpc.this.id}"
vpc_id = "${aws_vpc.mod.id}"
vpn_gateway_id = "${var.vpn_gateway_id}"
}

Expand Down
24 changes: 12 additions & 12 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
# VPC
output "vpc_id" {
description = "The ID of the VPC"
value = "${element(concat(aws_vpc.this.*.id, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.id, list("")), 0)}"
}

output "vpc_cidr_block" {
description = "The CIDR block of the VPC"
value = "${element(concat(aws_vpc.this.*.cidr_block, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.cidr_block, list("")), 0)}"
}

output "default_security_group_id" {
description = "The ID of the security group created by default on VPC creation"
value = "${element(concat(aws_vpc.this.*.default_security_group_id, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.default_security_group_id, list("")), 0)}"
}

output "default_network_acl_id" {
description = "The ID of the default network ACL"
value = "${element(concat(aws_vpc.this.*.default_network_acl_id, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.default_network_acl_id, list("")), 0)}"
}

output "default_route_table_id" {
description = "The ID of the default route table"
value = "${element(concat(aws_vpc.this.*.default_route_table_id, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.default_route_table_id, list("")), 0)}"
}

output "vpc_instance_tenancy" {
description = "Tenancy of instances spin up within VPC"
value = "${element(concat(aws_vpc.this.*.instance_tenancy, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.instance_tenancy, list("")), 0)}"
}

output "vpc_enable_dns_support" {
description = "Whether or not the VPC has DNS support"
value = "${element(concat(aws_vpc.this.*.enable_dns_support, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.enable_dns_support, list("")), 0)}"
}

output "vpc_enable_dns_hostnames" {
description = "Whether or not the VPC has DNS hostname support"
value = "${element(concat(aws_vpc.this.*.enable_dns_hostnames, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.enable_dns_hostnames, list("")), 0)}"
}

//output "vpc_enable_classiclink" {
// description = "Whether or not the VPC has Classiclink enabled"
// value = "${element(concat(aws_vpc.this.*.enable_classiclink, list("")), 0)}"
// value = "${element(concat(aws_vpc.mod.*.enable_classiclink, list("")), 0)}"
//}

output "vpc_main_route_table_id" {
description = "The ID of the main route table associated with this VPC"
value = "${element(concat(aws_vpc.this.*.main_route_table_id, list("")), 0)}"
value = "${element(concat(aws_vpc.mod.*.main_route_table_id, list("")), 0)}"
}

//output "vpc_ipv6_association_id" {
// description = "The association ID for the IPv6 CIDR block"
// value = "${element(concat(aws_vpc.this.*.ipv6_association_id, list("")), 0)}"
// value = "${element(concat(aws_vpc.mod.*.ipv6_association_id, list("")), 0)}"
//}
//
//output "vpc_ipv6_cidr_block" {
// description = "The IPv6 CIDR block"
// value = "${element(concat(aws_vpc.this.*.ipv6_cidr_block, list("")), 0)}"
// value = "${element(concat(aws_vpc.mod.*.ipv6_cidr_block, list("")), 0)}"
//}

# Subnets
Expand Down

0 comments on commit 8edc872

Please sign in to comment.