-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathh8-ALB-application-loadbalancer.tf
83 lines (75 loc) · 1.87 KB
/
h8-ALB-application-loadbalancer.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
75
76
77
78
79
80
81
82
83
module "alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 6.0"
name = "${local.name}-alb"
load_balancer_type = "application"
vpc_id = module.vpc.vpc_id
subnets = module.vpc.public_subnets
security_groups = [module.loadbalancer_sg.security_group_id]
# HTTP Listener - Redirect HTTPs
http_tcp_listeners = [
{
port = 80
protocol = "HTTP"
action_type = "redirect"
redirect = {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
}
]
# Target Group
target_groups = [
# App1 Target Group - TG Index = 0
{
name_prefix = "app-"
backend_protocol = "HTTP"
backend_port = 80
target_type = "instance"
health_check = {
enabled = true
interval = 30
path = "/index.html"
port = "traffic-port"
healthy_threshold = 3
unhealthy_threshold = 3
timeout = 6
protocol = "HTTP"
matcher = "200-299"
}
protocol_version = "HTTP1"
tags = local.common_tags
},
]
# HTTPs Listener
https_listeners = [
# HTTPS Listener Index = 0
{
port = 443
protocol = "HTTPS"
certificate_arn = module.acm.acm_certificate_arn
# action_type = "fixed-response"
# fixed_response = {
# content_type = "text/plain"
# message_body = "Fixed Static Message"
# status_code = "200"
# }
}
]
https_listener_rules = [
{
https_listener_index = 0
actions = [
{
type = "forward"
target_group_index = 0
}
]
conditions= [{
path_patterns = ["/*"]
}]
}
]
tags = local.common_tags
}