forked from wardviaene/terraform-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lb.tf
53 lines (48 loc) · 1.3 KB
/
lb.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
resource "aws_lb" "demo" {
name = "demo"
subnets = module.vpc.public_subnets
load_balancer_type = "network"
enable_cross_zone_load_balancing = true
}
resource "aws_lb_listener" "demo" {
load_balancer_arn = aws_lb.demo.arn
port = "80"
protocol = "TCP"
default_action {
target_group_arn = aws_lb_target_group.demo-blue.id
type = "forward"
}
lifecycle {
ignore_changes = [
default_action,
]
}
}
resource "aws_lb_target_group" "demo-blue" {
name = "demo-http-blue"
port = "3000"
protocol = "TCP"
target_type = "ip"
vpc_id = module.vpc.vpc_id
deregistration_delay = "30"
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
protocol = "TCP"
interval = 30
}
}
resource "aws_lb_target_group" "demo-green" {
name = "demo-http-green"
port = "3000"
protocol = "TCP"
target_type = "ip"
vpc_id = module.vpc.vpc_id
deregistration_delay = "30"
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
protocol = "TCP"
interval = 30
}
}