-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroute_table.tf
62 lines (50 loc) · 1.7 KB
/
route_table.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
#----------------------------------------------
# Route tables for all subnets are defined here
#----------------------------------------------
# Public Subnet route table
resource "aws_route_table" "public_rt" {
vpc_id = "${aws_vpc.wordpress_vpc.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.wordpress_ig.id}"
}
tags {
Name = "PublicRouteTable"
}
}
# Private subnet route table
resource "aws_route_table" "private_rt" {
vpc_id = "${aws_vpc.wordpress_vpc.id}"
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.wordpress_environment_natgateway.id}"
}
tags {
Name = "private_rt"
}
}
# Route table association wih subnets
resource "aws_route_table_association" "public_subnet_rt_sssociation_1" {
subnet_id = "${aws_subnet.public1.id}"
route_table_id = "${aws_route_table.public_rt.id}"
}
resource "aws_route_table_association" "public_subnet_rt_sssociation_2" {
subnet_id = "${aws_subnet.public2.id}"
route_table_id = "${aws_route_table.public_rt.id}"
}
resource "aws_route_table_association" "app_subnet_rt_association_1" {
subnet_id = "${aws_subnet.app1.id}"
route_table_id = "${aws_route_table.private_rt.id}"
}
resource "aws_route_table_association" "app_subnet_rt_association_2" {
subnet_id = "${aws_subnet.app2.id}"
route_table_id = "${aws_route_table.private_rt.id}"
}
resource "aws_route_table_association" "db_subnet_rt_association_1" {
subnet_id = "${aws_subnet.db1.id}"
route_table_id = "${aws_route_table.private_rt.id}"
}
resource "aws_route_table_association" "db_subnet_rt_association_2" {
subnet_id = "${aws_subnet.db2.id}"
route_table_id = "${aws_route_table.private_rt.id}"
}