-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.tf
95 lines (78 loc) · 2.7 KB
/
routes.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
Public Route
*/
resource "aws_route_table" "public" {
vpc_id = "${aws_vpc.main.id}"
tags = {
Name = "Public Route"
}
}
resource "aws_route" "public_igw" {
route_table_id = "${aws_route_table.public.id}"
destination_cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.main.id}"
depends_on = ["aws_route_table.public"]
}
resource "aws_route" "vpn_gw_public" {
route_table_id = "${aws_route_table.public.id}"
destination_cidr_block = "${var.vpn_internal_cidr}"
gateway_id = "${aws_vpn_gateway.vpn_gw.id}"
depends_on = ["aws_route_table.public"]
}
/*
Private Routes
*/
resource "aws_route_table" "private_a" {
vpc_id = "${aws_vpc.main.id}"
tags = {
Name = "Private Route AZ A"
}
}
resource "aws_route" "private_igw_a" {
route_table_id = "${aws_route_table.private_a.id}"
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id ="${aws_nat_gateway.private_gw_a.id}"
depends_on = ["aws_route_table.private_a"]
}
resource "aws_route" "vpn_gw_private_a" {
route_table_id = "${aws_route_table.private_a.id}"
destination_cidr_block = "${var.vpn_internal_cidr}"
gateway_id = "${aws_vpn_gateway.vpn_gw.id}"
depends_on = ["aws_route_table.private_a"]
}
resource "aws_route_table" "private_b" {
vpc_id = "${aws_vpc.main.id}"
tags = {
Name = "Private Route AZ B"
}
}
resource "aws_route" "private_igw_b" {
route_table_id = "${aws_route_table.private_b.id}"
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.private_gw_b.id}"
depends_on = ["aws_route_table.private_b"]
}
resource "aws_route" "vpn_gw_private_b" {
route_table_id = "${aws_route_table.private_b.id}"
destination_cidr_block = "${var.vpn_internal_cidr}"
gateway_id = "${aws_vpn_gateway.vpn_gw.id}"
depends_on = ["aws_route_table.private_b"]
}
resource "aws_route_table" "private_c" {
vpc_id = "${aws_vpc.main.id}"
tags = {
Name = "Private Route AZ C"
}
}
resource "aws_route" "private_igw_c" {
route_table_id = "${aws_route_table.private_c.id}"
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.private_gw_c.id}"
depends_on = ["aws_route_table.private_c"]
}
resource "aws_route" "vpn_gw_private_c" {
route_table_id = "${aws_route_table.private_c.id}"
destination_cidr_block = "${var.vpn_internal_cidr}"
gateway_id = "${aws_vpn_gateway.vpn_gw.id}"
depends_on = ["aws_route_table.private_c"]
}