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

Commit 8edc872

Browse files
committed
Enable backwards compatibility
1 parent f7a874c commit 8edc872

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
terraform.tfstate
55
terraform.tfvars
66
Gemfile.lock
7+
.idea

main.tf

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ locals {
1010
######
1111
# VPC
1212
######
13-
resource "aws_vpc" "this" {
13+
resource "aws_vpc" "mod" {
1414
count = "${var.create_vpc ? 1 : 0}"
1515

1616
cidr_block = "${var.cidr}"
@@ -42,7 +42,7 @@ resource "aws_vpc_dhcp_options" "this" {
4242
resource "aws_vpc_dhcp_options_association" "this" {
4343
count = "${var.create_vpc && var.enable_dhcp_options ? 1 : 0}"
4444

45-
vpc_id = "${aws_vpc.this.id}"
45+
vpc_id = "${aws_vpc.mod.id}"
4646
dhcp_options_id = "${aws_vpc_dhcp_options.this.id}"
4747
}
4848

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

55-
vpc_id = "${aws_vpc.this.id}"
55+
vpc_id = "${aws_vpc.mod.id}"
5656

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

66-
vpc_id = "${aws_vpc.this.id}"
66+
vpc_id = "${aws_vpc.mod.id}"
6767

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

90-
vpc_id = "${aws_vpc.this.id}"
90+
vpc_id = "${aws_vpc.mod.id}"
9191

9292
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)}"
9393

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

107-
vpc_id = "${aws_vpc.this.id}"
107+
vpc_id = "${aws_vpc.mod.id}"
108108

109109
tags = "${merge(map("Name", "${var.name}-intra"), var.intra_route_table_tags, var.tags)}"
110110
}
@@ -115,7 +115,7 @@ resource "aws_route_table" "intra" {
115115
resource "aws_subnet" "public" {
116116
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}"
117117

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

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

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

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

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

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

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

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

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

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

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

277-
vpc_id = "${aws_vpc.this.id}"
277+
vpc_id = "${aws_vpc.mod.id}"
278278
service_name = "${data.aws_vpc_endpoint_service.s3.service_name}"
279279
}
280280

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

314-
vpc_id = "${aws_vpc.this.id}"
314+
vpc_id = "${aws_vpc.mod.id}"
315315
service_name = "${data.aws_vpc_endpoint_service.dynamodb.service_name}"
316316
}
317317

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

390-
vpc_id = "${aws_vpc.this.id}"
390+
vpc_id = "${aws_vpc.mod.id}"
391391

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

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

398-
vpc_id = "${aws_vpc.this.id}"
398+
vpc_id = "${aws_vpc.mod.id}"
399399
vpn_gateway_id = "${var.vpn_gateway_id}"
400400
}
401401

outputs.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
# VPC
22
output "vpc_id" {
33
description = "The ID of the VPC"
4-
value = "${element(concat(aws_vpc.this.*.id, list("")), 0)}"
4+
value = "${element(concat(aws_vpc.mod.*.id, list("")), 0)}"
55
}
66

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

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

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

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

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

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

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

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

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

5252
//output "vpc_ipv6_association_id" {
5353
// description = "The association ID for the IPv6 CIDR block"
54-
// value = "${element(concat(aws_vpc.this.*.ipv6_association_id, list("")), 0)}"
54+
// value = "${element(concat(aws_vpc.mod.*.ipv6_association_id, list("")), 0)}"
5555
//}
5656
//
5757
//output "vpc_ipv6_cidr_block" {
5858
// description = "The IPv6 CIDR block"
59-
// value = "${element(concat(aws_vpc.this.*.ipv6_cidr_block, list("")), 0)}"
59+
// value = "${element(concat(aws_vpc.mod.*.ipv6_cidr_block, list("")), 0)}"
6060
//}
6161

6262
# Subnets

0 commit comments

Comments
 (0)