-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_balancer.tf
45 lines (37 loc) · 990 Bytes
/
load_balancer.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
resource "aws_alb" "load_balancer" {
name = "example-load-balancer"
subnets = local.public_subnets
security_groups = [
aws_security_group.load_balancer.id,
aws_security_group.interservice.id
]
}
resource "aws_lb_listener" "http" {
load_balancer_arn = aws_alb.load_balancer.id
port = 80
protocol = "HTTP"
default_action {
target_group_arn = aws_alb_target_group.service.id
type = "forward"
}
}
resource "aws_alb_target_group" "service" {
name = "example-service"
target_type = "ip"
protocol = "HTTP"
deregistration_delay = 10
port = local.host_port
vpc_id = local.vpc_id
health_check {
path = "/"
port = local.host_port
protocol = "HTTP"
matcher = 200
timeout = 5
healthy_threshold = 3
unhealthy_threshold = 3
}
lifecycle {
create_before_destroy = true
}
}