forked from willfarrell/terraform-vpc-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubnet_private.tf
53 lines (44 loc) · 1.08 KB
/
subnet_private.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
resource "aws_subnet" "private" {
count = local.az_count
vpc_id = aws_vpc.main.id
cidr_block = local.private-cidr[count.index]
availability_zone = local.az_name[count.index]
tags = merge(
local.tags,
{
Name = "${local.az_name[count.index]}-private-${local.name}"
}
)
}
resource "aws_route_table" "private" {
count = var.nat_type == "none" ? local.az_count : 0
vpc_id = aws_vpc.main.id
dynamic "route" {
for_each = aws_vpc_endpoint.main
content {
vpc_endpoint_id = route.value.id
}
}
tags = merge(
local.tags,
{
Name = "private-${local.name}-${local.az_name[count.index]}"
}
)
}
resource "aws_route_table_association" "private" {
count = var.nat_type == "none" ? local.az_count : 0
subnet_id = aws_subnet.private[count.index].id
route_table_id = aws_route_table.private[count.index].id
}
# ACL
resource "aws_network_acl" "private" {
vpc_id = aws_vpc.main.id
subnet_ids = aws_subnet.private.*.id
tags = merge(
local.tags,
{
Name = "private-${local.name}"
}
)
}