-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalb.tf
More file actions
35 lines (31 loc) · 888 Bytes
/
alb.tf
File metadata and controls
35 lines (31 loc) · 888 Bytes
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
resource "aws_lb" "alb" {
name = "${var.project_names}-alb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.alb_sg.id]
subnets = aws_subnet.public_subnets[*].id
}
resource "aws_lb_target_group" "ecs_tg" {
name = "${var.project_names}-tg"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.main_vpc.id
target_type = "ip"
health_check {
path = "/"
interval = 30
timeout = 5
healthy_threshold = 3
unhealthy_threshold = 2
matcher = "200-299"
}
}
resource "aws_lb_listener" "alb_listener" {
load_balancer_arn = aws_lb.alb.arn
port = 80
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.ecs_tg.arn
}
}