-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathroute.tf
47 lines (40 loc) · 1.31 KB
/
route.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
resource "aws_route_table" "public_route_table" {
vpc_id = aws_vpc.eks_vpc.id
tags = merge(
local.common_tags,
{
Name = "public-route"
}
)
}
resource "aws_route_table" "private_route_table" {
vpc_id = aws_vpc.eks_vpc.id
tags = merge(
local.common_tags,
{
Name = "private-route"
}
)
}
resource "aws_route" "public_route" {
route_table_id = aws_route_table.public_route_table.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.eks_igw.id
depends_on = [aws_internet_gateway.eks_igw]
}
resource "aws_route" "private_route" {
route_table_id = aws_route_table.private_route_table.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_nat_gateway.private_nat.id
depends_on = [aws_nat_gateway.private_nat]
}
resource "aws_route_table_association" "public_rt_assoc" {
count = length(local.public_subnets)
subnet_id = element(aws_subnet.public_subnet.*.id, count.index)
route_table_id = aws_route_table.public_route_table.id
}
resource "aws_route_table_association" "private_rt_assoc" {
count = length(local.private_subnets)
subnet_id = element(aws_subnet.private_subnet.*.id, count.index)
route_table_id = aws_route_table.private_route_table.id
}