-
Notifications
You must be signed in to change notification settings - Fork 0
/
alb.tf
60 lines (50 loc) · 1.49 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
60
##################################################
# LB in Pub subnet
##################################################
resource "aws_lb" "web_lb" {
name = "web-lb"
internal = false
load_balancer_type = "application"
subnets = aws_subnet.pub_subnet[*].id
enable_deletion_protection = false
tags = local.common_tags
}
##################################################
# LB Target Group
##################################################
resource "aws_alb_target_group" "tg" {
name = "web-lb-tg"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.vpc.id
# Health check configuration
health_check {
path = "/health"
interval = 30
timeout = 10
healthy_threshold = 2
unhealthy_threshold = 2
}
}
##################################################
# AutoScaling Attachment
##################################################
resource "aws_autoscaling_attachment" "asg_ass" {
autoscaling_group_name = aws_autoscaling_group.asg.id
lb_target_group_arn = aws_alb_target_group.tg.arn
}
##################################################
# LB Listener
##################################################
resource "aws_lb_listener" "web_lb_listener" {
load_balancer_arn = aws_lb.web_lb.arn
port = 80
protocol = "HTTP"
default_action {
type = "fixed-response"
fixed_response {
content_type = "text/plain"
status_code = "200"
}
}
}