-
Notifications
You must be signed in to change notification settings - Fork 0
/
alb.tf
74 lines (69 loc) · 1.85 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
62
63
64
65
66
67
68
69
70
71
72
73
74
module "alb" {
source = "terraform-aws-modules/alb/aws"
name = format(module.naming.result, "alb")
load_balancer_type = "application"
vpc_id = module.vpc.vpc_id
subnets = module.vpc.public_subnets
security_groups = [module.security_group_for_alb.security_group_id]
enable_deletion_protection = false
target_groups = {
backend = {
name = format(module.naming.result, "backend-tg")
backend_protocol = "HTTP"
backend_port = 8080
target_type = "instance"
target_id = module.backend.id
health_check = {
enabled = true
interval = 30
path = "/api/health"
port = "traffic-port"
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 6
protocol = "HTTP"
matcher = "200-399"
}
create_attachment = false
}
}
listeners = {
http-redirect = {
port = 80
protocol = "HTTP"
redirect = {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
}
https = {
port = 443
protocol = "HTTPS"
certificate_arn = module.acm_ap_northeast_2.acm_certificate_arn
fixed_response = {
content_type = "text/plain"
status_code = 403
message_body = "invalid access"
}
rules = {
backend-rule = {
priority = 1
actions = [
{
type = "forward"
target_group_key = "backend"
}
]
conditions = [
{
host_header = {
values = ["api.${var.domain_name}"]
}
}
]
}
}
}
}
}