-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalb.tf
61 lines (51 loc) · 1.55 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
61
resource "aws_lb" "fphs" {
name = local.name
internal = false
load_balancer_type = "application"
subnets = aws_subnet.public.*.id
security_groups = [aws_security_group.fphs_lb.id]
access_logs {
bucket = aws_s3_bucket.fphs_logs.bucket
prefix = "lb"
enabled = true
}
tags = local.common_tags
}
resource "aws_lb_target_group" "fphs" {
name = local.name
port = var.app_port
protocol = "HTTP"
target_type = "ip"
load_balancing_algorithm_type = "least_outstanding_requests"
vpc_id = aws_vpc.fphs.id
health_check {
path = "/health/"
matcher = "200"
enabled = true
}
tags = local.common_tags
}
resource "aws_lb_listener" "fphs_app" {
load_balancer_arn = aws_lb.fphs.arn
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = aws_acm_certificate_validation.fphs.certificate_arn
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.fphs.arn
}
}
resource "aws_lb_listener" "fphs_redirect" {
load_balancer_arn = aws_lb.fphs.arn
port = "80"
protocol = "HTTP"
default_action {
type = "redirect"
redirect {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
}
}