-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadbalancer.tf
42 lines (36 loc) · 966 Bytes
/
loadbalancer.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
resource "aws_lb" "main" {
name = "${var.name}-alb"
load_balancer_type = "application"
subnets = aws_subnet.public[*].id
security_groups = [aws_security_group.http.id]
}
resource "aws_lb_target_group" "app" {
name_prefix = "app-"
vpc_id = aws_vpc.main.id
protocol = "HTTP"
port = 80
#NOTE - incompatible with network mode host/bridge
# target_type = "ip"
health_check {
enabled = true
path = "/"
port = 80
matcher = 200
interval = 10
timeout = 5
healthy_threshold = 2
unhealthy_threshold = 3
}
}
resource "aws_lb_listener" "http" {
load_balancer_arn = aws_lb.main.id
port = 80
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.app.id
}
}
output "alb_url" {
value = aws_lb.main.dns_name
}