-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_network.tf
105 lines (87 loc) · 1.97 KB
/
01_network.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
96
97
98
99
100
101
102
103
104
105
resource "aws_vpc" "kiddie" {
cidr_block = var.vpc_cidr_block
assign_generated_ipv6_cidr_block = true
tags = merge(
var.tags,
map(
"Name", "Kiddie"
)
)
}
resource "aws_internet_gateway" "kiddie" {
vpc_id = aws_vpc.kiddie.id
tags = merge(
var.tags,
map(
"Name", "Kiddie"
)
)
}
resource "aws_egress_only_internet_gateway" "kiddie" {
vpc_id = aws_vpc.kiddie.id
tags = merge(
var.tags,
map(
"Name", "Kiddie"
)
)
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.kiddie.id
cidr_block = var.public_subnet_cidr_block
availability_zone = "${var.region}a"
tags = merge(
var.tags,
map(
"Name", "KiddiePublic"
)
)
}
resource "aws_route_table" "public" {
vpc_id = aws_vpc.kiddie.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.kiddie.id
}
tags = merge(
var.tags,
map(
"Name", "KiddiePublic"
)
)
}
resource "aws_route_table_association" "public" {
subnet_id = aws_subnet.public.id
route_table_id = aws_route_table.public.id
}
resource "aws_subnet" "private" {
vpc_id = aws_vpc.kiddie.id
cidr_block = var.private_subnet_cidr_block
availability_zone = "${var.region}b"
assign_ipv6_address_on_creation = true
ipv6_cidr_block = cidrsubnet(aws_vpc.kiddie.ipv6_cidr_block, 8, 0)
tags = merge(
var.tags,
map(
"Name", "KiddiePrivate"
)
)
}
resource "aws_route_table" "private" {
vpc_id = aws_vpc.kiddie.id
tags = merge(
var.tags,
map(
"Name", "KiddiePrivate"
)
)
}
resource "aws_route" "private_eigw" {
route_table_id = aws_route_table.private.id
destination_ipv6_cidr_block = "::/0"
egress_only_gateway_id = aws_egress_only_internet_gateway.kiddie.id
}
resource "aws_route_table_association" "private" {
subnet_id = aws_subnet.private.id
route_table_id = aws_route_table.private.id
}