-
Notifications
You must be signed in to change notification settings - Fork 0
/
rt.tf
67 lines (48 loc) · 1.43 KB
/
rt.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
resource "aws_route_table" "public_route_table" {
for_each = var.vpcs
vpc_id = aws_vpc.network[each.key].id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw[each.key].id
}
tags = {
Name = "Public-Route-Table-${each.key}"
}
}
resource "aws_eip" "nat_eip" {
for_each = var.vpcs
tags = {
Name = "NAT-Gateway-EIP-${each.key}"
}
}
resource "aws_nat_gateway" "nat" {
for_each = var.vpcs
allocation_id = aws_eip.nat_eip[each.key].id
subnet_id = aws_subnet.external_subnet[each.key].id
tags = {
Name = "NAT-Gateway-${each.key}"
}
}
resource "aws_route_table" "private_route_table" {
for_each = var.vpcs
vpc_id = aws_vpc.network[each.key].id
tags = {
Name = "Private-Route-Table-${each.key}"
}
}
#Route Table Associations
resource "aws_route_table_association" "public_association" {
for_each = var.vpcs
subnet_id = aws_subnet.external_subnet[each.key].id
route_table_id = aws_route_table.public_route_table[each.key].id
}
resource "aws_route_table_association" "private_association_internal" {
for_each = var.vpcs
subnet_id = aws_subnet.internal_subnet[each.key].id
route_table_id = aws_route_table.private_route_table[each.key].id
}
resource "aws_route_table_association" "private_association_db" {
for_each = var.vpcs
subnet_id = aws_subnet.db_subnet[each.key].id
route_table_id = aws_route_table.private_route_table[each.key].id
}