-
Notifications
You must be signed in to change notification settings - Fork 127
/
alb.tf
59 lines (55 loc) · 1.33 KB
/
alb.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
resource "aws_lb" "test-lb" {
name = "test-ecs-lb"
load_balancer_type = "application"
internal = false
subnets = module.vpc.public_subnets
tags = {
"env" = "dev"
"createdBy" = "mkerimova"
}
security_groups = [aws_security_group.lb.id]
}
resource "aws_security_group" "lb" {
name = "allow-all-lb"
vpc_id = data.aws_vpc.main.id
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
"env" = "dev"
"createdBy" = "mkerimova"
}
}
resource "aws_lb_target_group" "lb_target_group" {
name = "masha-target-group"
port = "80"
protocol = "HTTP"
target_type = "instance"
vpc_id = data.aws_vpc.main.id
health_check {
path = "/"
healthy_threshold = 2
unhealthy_threshold = 10
timeout = 60
interval = 300
matcher = "200,301,302"
}
}
resource "aws_lb_listener" "web-listener" {
load_balancer_arn = aws_lb.test-lb.arn
port = "80"
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.lb_target_group.arn
}
}