-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalb.tf
More file actions
90 lines (76 loc) · 2.4 KB
/
Copy pathalb.tf
File metadata and controls
90 lines (76 loc) · 2.4 KB
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
################################ Load Balancer Blue ###########################################
resource "aws_alb" "blue-lb" {
name = "Blue-${var.customer}-${var.appname}-${var.ZONE}-${var.envr}"
security_groups = ["${aws_security_group.alb.id}"]
subnets = ["${aws_subnet.public_subnet.*.id}"]
tags = {
Name = "Blue-${var.customer}-${var.appname}-${var.ZONE}-${var.envr}"
}
}
################################# Target Group For Blue Deployment ###############################
resource "aws_alb_target_group" "blue-tg" {
name = "Blue-${var.customer}-${var.appname}-${var.ZONE}-${var.envr}"
port = "80"
protocol = "HTTP"
vpc_id = "${aws_vpc.main.id}"
health_check {
healthy_threshold = "5"
unhealthy_threshold = "2"
interval = "30"
matcher = "200-499"
path = "/"
port = "traffic-port"
protocol = "HTTP"
timeout = "5"
}
tags = {
Name = "Blue-${var.customer}-${var.appname}-${var.ZONE}-${var.envr}"
}
}
resource "aws_alb_listener" "blue-listener" {
load_balancer_arn = "${aws_alb.blue-lb.arn}"
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.blue-tg.arn}"
type = "forward"
}
depends_on = [
"aws_alb.blue-lb",
]
}
output "Blue-tg-arn" {
value = "${aws_alb_target_group.blue-tg.arn}"
}
# ############################################## Target Group for Green Deployment #######################
resource "aws_alb_target_group" "green-tg" {
name = "Green-${var.customer}-${var.appname}-${var.ZONE}-${var.envr}"
port = "80"
protocol = "HTTP"
vpc_id = "${aws_vpc.main.id}"
health_check {
healthy_threshold = "5"
unhealthy_threshold = "2"
interval = "30"
matcher = "200-399"
path = "/"
port = "traffic-port"
protocol = "HTTP"
timeout = "5"
}
tags = {
Name = "Green-${var.customer}-${var.appname}-${var.ZONE}-${var.envr}"
}
}
resource "aws_alb_listener" "green-listener" {
load_balancer_arn = "${aws_alb.blue-lb.arn}"
port = "8080"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.green-tg.arn}"
type = "forward"
}
depends_on = [
"aws_alb.blue-lb",
]
}