-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadbalance.tf
102 lines (89 loc) · 2.2 KB
/
loadbalance.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
resource "aws_lb" "jenkins_master" {
name = var.public_load_balancer_name
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.jenkins_master_public_lb_sg.id]
subnets = [module.vpc.public_subnets[0], module.vpc.public_subnets[1], module.vpc.public_subnets[2]]
# enable_deletion_protection = true
enable_deletion_protection = false
tags = merge(
var.tags
)
depends_on = [
module.vpc
]
}
resource "aws_lb_target_group" "ecs_jenkins_master" {
name = var.lb_target_group_name
port = 80
protocol = "HTTP"
target_type = "ip"
vpc_id = module.vpc.vpc_id
health_check {
interval = 60
path = "/login"
port = 8080
protocol = "HTTP"
timeout = 10
unhealthy_threshold = 5
healthy_threshold = 5
matcher = "200"
}
tags = merge(
var.tags
)
depends_on = [
aws_lb.jenkins_master
]
}
resource "aws_lb_listener" "jenkins_master" {
load_balancer_arn = aws_lb.jenkins_master.arn
port = 443
protocol = "HTTPS"
certificate_arn = data.aws_acm_certificate.jenkins.arn
default_action {
target_group_arn = aws_lb_target_group.ecs_jenkins_master.arn
type = "forward"
}
tags = merge(
var.tags
)
depends_on = [
aws_lb.jenkins_master
]
}
resource "aws_lb_listener" "redirect_to_443" {
load_balancer_arn = aws_lb.jenkins_master.arn
port = "80"
protocol = "HTTP"
default_action {
type = "redirect"
redirect {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
}
tags = merge(
var.tags
)
depends_on = [
aws_lb.jenkins_master
]
}
# if you don't need to use HTTPS as the ingress:
/* resource "aws_lb_listener" "jenkins_master" {
load_balancer_arn = aws_lb.jenkins_master.arn
port = 80
protocol = "HTTP"
default_action {
target_group_arn = aws_lb_target_group.ecs_jenkins_master.arn
type = "forward"
}
tags = merge(
var.tags
)
depends_on = [
aws_lb.jenkins_master
]
} */