-
Notifications
You must be signed in to change notification settings - Fork 0
/
public_subnet.tf
95 lines (61 loc) · 1.62 KB
/
public_subnet.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
resource "aws_subnet" "public_subnet1" {
depends_on = [
aws_vpc.main
]
vpc_id = aws_vpc.main.id
cidr_block = var.public_cidr1
availability_zone = data.aws_availability_zones.available.names[0]
map_public_ip_on_launch = var.map_public_ip_on_launch
tags = var.tags
}
resource "aws_subnet" "public_subnet2" {
depends_on = [
aws_vpc.main
]
vpc_id = aws_vpc.main.id
cidr_block = var.public_cidr2
availability_zone = data.aws_availability_zones.available.names[1]
map_public_ip_on_launch = var.map_public_ip_on_launch
tags = var.tags
}
resource "aws_subnet" "public_subnet3" {
depends_on = [
aws_vpc.main
]
vpc_id = aws_vpc.main.id
cidr_block = var.public_cidr3
availability_zone = data.aws_availability_zones.available.names[2]
map_public_ip_on_launch = var.map_public_ip_on_launch
tags = var.tags
}
//
resource "aws_internet_gateway" "gw" {
vpc_id = aws_vpc.main.id
tags = var.tags
}
//
resource "aws_route_table" "public" {
depends_on = [
aws_vpc.main,
aws_internet_gateway.gw
]
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
}
tags = var.tags
}
//
resource "aws_route_table_association" "public1" {
subnet_id = aws_subnet.public_subnet1.id
route_table_id = aws_route_table.public.id
}
resource "aws_route_table_association" "public2" {
subnet_id = aws_subnet.public_subnet2.id
route_table_id = aws_route_table.public.id
}
resource "aws_route_table_association" "public3" {
subnet_id = aws_subnet.public_subnet3.id
route_table_id = aws_route_table.public.id
}