-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend-vpc.tf
71 lines (58 loc) · 1.3 KB
/
backend-vpc.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
resource "aws_subnet" "backend_a" {
vpc_id = aws_vpc.vpc.id
cidr_block = "172.16.1.0/24"
availability_zone = "ap-northeast-2a"
tags = {
Name = "parkingspace-subnet-backend-a"
}
}
resource "aws_subnet" "backend_c" {
vpc_id = aws_vpc.vpc.id
cidr_block = "172.16.2.0/24"
availability_zone = "ap-northeast-2c"
tags = {
Name = "parkingspace-subnet-backend-c"
}
}
resource "aws_route_table_association" "backend_a" {
subnet_id = aws_subnet.backend_a.id
route_table_id = aws_route_table.rtb.id
}
resource "aws_route_table_association" "backend_c" {
subnet_id = aws_subnet.backend_c.id
route_table_id = aws_route_table.rtb.id
}
resource "aws_security_group" "backend" {
vpc_id = aws_vpc.vpc.id
name = "parkingspace-sg-backend"
ingress {
from_port = 3000
to_port = 3000
protocol = "TCP"
security_groups = [
aws_security_group.backend_elb.id
]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_security_group" "backend_elb" {
vpc_id = aws_vpc.vpc.id
name = "parkingspace-sg-elb"
ingress {
cidr_blocks = ["0.0.0.0/0"]
from_port = 80
to_port = 80
protocol = "TCP"
}
egress {
cidr_blocks = ["0.0.0.0/0"]
to_port = 0
from_port = 0
protocol = "-1"
}
}