-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlb.tf
55 lines (48 loc) · 1.39 KB
/
lb.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
resource "aws_lb_target_group" "taskoverflow" {
name = "taskoverflow"
port = 6400
protocol = "HTTP"
vpc_id = aws_security_group.taskoverflow_lb.vpc_id
target_type = "ip"
health_check {
path = "/api/v1/health"
port = "6400"
protocol = "HTTP"
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 5
interval = 10
}
}
resource "aws_lb" "taskoverflow" {
name = "taskoverflow"
internal = false
load_balancer_type = "application"
subnets = data.aws_subnets.private.ids
security_groups = [aws_security_group.taskoverflow_lb.id]
}
resource "aws_security_group" "taskoverflow_lb" {
name = "taskoverflow_lb"
description = "TaskOverflow Security Group for load balancer"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_lb_listener" "taskoverflow" {
load_balancer_arn = aws_lb.taskoverflow.arn
port = "80"
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.taskoverflow.arn
}
}