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

KAN-380 terraform 0.12 upgrade #1

Merged
merged 1 commit into from
May 3, 2021
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
1 change: 1 addition & 0 deletions .terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12.11
64 changes: 32 additions & 32 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ resource "aws_vpc_dhcp_options" "this" {
count = "${var.create_vpc && var.enable_dhcp_options ? 1 : 0}"

domain_name = "${var.dhcp_options_domain_name}"
domain_name_servers = ["${var.dhcp_options_domain_name_servers}"]
ntp_servers = ["${var.dhcp_options_ntp_servers}"]
netbios_name_servers = ["${var.dhcp_options_netbios_name_servers}"]
domain_name_servers = "${var.dhcp_options_domain_name_servers}"
ntp_servers = "${var.dhcp_options_ntp_servers}"
netbios_name_servers = "${var.dhcp_options_netbios_name_servers}"
netbios_node_type = "${var.dhcp_options_netbios_node_type}"

tags = "${merge(map("Name", format("%s", var.name)), var.dhcp_options_tags, var.tags)}"
Expand All @@ -42,8 +42,8 @@ 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.mod.id}"
dhcp_options_id = "${aws_vpc_dhcp_options.this.id}"
vpc_id = "${aws_vpc.mod[count.index].id}"
dhcp_options_id = "${aws_vpc_dhcp_options.this[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].id}"

tags = "${merge(map("Name", format("%s", var.name)), var.igw_tags, var.tags)}"
}
Expand All @@ -63,17 +63,17 @@ 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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].id}"

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

resource "aws_route" "public_internet_gateway" {
count = "${var.create_vpc && length(var.public_subnets) > 0 ? 1 : 0}"

route_table_id = "${aws_route_table.public.id}"
route_table_id = "${aws_route_table.public[count.index].id}"
destination_cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.this.id}"
gateway_id = "${aws_internet_gateway.this[count.index].id}"

timeouts {
create = "5m"
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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].id}"
cidr_block = "${var.intra_subnets[count.index]}"
availability_zone = "${element(var.azs, count.index)}"

Expand Down Expand Up @@ -274,29 +274,29 @@ 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.mod.id}"
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"
vpc_id = "${aws_vpc.mod[count.index].id}"
service_name = "${data.aws_vpc_endpoint_service.s3[count.index].service_name}"
}

resource "aws_vpc_endpoint_route_table_association" "private_s3" {
count = "${var.create_vpc && var.enable_s3_endpoint ? local.nat_gateway_count : 0}"

vpc_endpoint_id = "${aws_vpc_endpoint.s3.id}"
vpc_endpoint_id = "${aws_vpc_endpoint.s3[count.index].id}"
route_table_id = "${element(aws_route_table.private.*.id, count.index)}"
}

resource "aws_vpc_endpoint_route_table_association" "intra_s3" {
count = "${var.create_vpc && var.enable_s3_endpoint && length(var.intra_subnets) > 0 ? 1 : 0}"

vpc_endpoint_id = "${aws_vpc_endpoint.s3.id}"
vpc_endpoint_id = "${aws_vpc_endpoint.s3[count.index].id}"
route_table_id = "${element(aws_route_table.intra.*.id, 0)}"
}

resource "aws_vpc_endpoint_route_table_association" "public_s3" {
count = "${var.create_vpc && var.enable_s3_endpoint && length(var.public_subnets) > 0 ? 1 : 0}"

vpc_endpoint_id = "${aws_vpc_endpoint.s3.id}"
route_table_id = "${aws_route_table.public.id}"
vpc_endpoint_id = "${aws_vpc_endpoint.s3[count.index].id}"
route_table_id = "${aws_route_table.public[count.index].id}"
}

############################
Expand All @@ -311,29 +311,29 @@ 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.mod.id}"
service_name = "${data.aws_vpc_endpoint_service.dynamodb.service_name}"
vpc_id = "${aws_vpc.mod[count.index].id}"
service_name = "${data.aws_vpc_endpoint_service.dynamodb[count.index].service_name}"
}

resource "aws_vpc_endpoint_route_table_association" "private_dynamodb" {
count = "${var.create_vpc && var.enable_dynamodb_endpoint ? local.nat_gateway_count : 0}"

vpc_endpoint_id = "${aws_vpc_endpoint.dynamodb.id}"
vpc_endpoint_id = "${aws_vpc_endpoint.dynamodb[count.index].id}"
route_table_id = "${element(aws_route_table.private.*.id, count.index)}"
}

resource "aws_vpc_endpoint_route_table_association" "intra_dynamodb" {
count = "${var.create_vpc && var.enable_dynamodb_endpoint && length(var.intra_subnets) > 0 ? 1 : 0}"

vpc_endpoint_id = "${aws_vpc_endpoint.dynamodb.id}"
vpc_endpoint_id = "${aws_vpc_endpoint.dynamodb[count.index].id}"
route_table_id = "${element(aws_route_table.intra.*.id, 0)}"
}

resource "aws_vpc_endpoint_route_table_association" "public_dynamodb" {
count = "${var.create_vpc && var.enable_dynamodb_endpoint && length(var.public_subnets) > 0 ? 1 : 0}"

vpc_endpoint_id = "${aws_vpc_endpoint.dynamodb.id}"
route_table_id = "${aws_route_table.public.id}"
vpc_endpoint_id = "${aws_vpc_endpoint.dynamodb[count.index].id}"
route_table_id = "${aws_route_table.public[count.index].id}"
}

##########################
Expand Down Expand Up @@ -378,7 +378,7 @@ resource "aws_route_table_association" "public" {
count = "${var.create_vpc && length(var.public_subnets) > 0 ? length(var.public_subnets) : 0}"

subnet_id = "${element(aws_subnet.public.*.id, count.index)}"
route_table_id = "${aws_route_table.public.id}"
route_table_id = "${aws_route_table.public[count.index].id}"
}

##############
Expand All @@ -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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].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.mod.id}"
vpc_id = "${aws_vpc.mod[count.index].id}"
vpn_gateway_id = "${var.vpn_gateway_id}"
}

Expand Down