Skip to content

Commit 6a1cf41

Browse files
committed
Use initial target group variable
* Set the variable for preview since the currently active target group is green
1 parent 0da26aa commit 6a1cf41

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

terraform/app/ecs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ module "web_service" {
146146
vpc_id = aws_vpc.application_vpc.id
147147
}
148148
loadbalancer = {
149-
target_group_arn = aws_lb_target_group.green.arn
149+
target_group_arn = local.ecs_initial_lb_target_group
150150
container_port = 4000
151151
}
152152
cluster_id = aws_ecs_cluster.cluster.id

terraform/app/env/preview.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ http_hosts = {
2626

2727
minimum_replicas = 3
2828
appspec_bucket = "nhse-mavis-appspec-bucket-preview"
29+
ecs_initial_lb_target_group = "green"

terraform/app/loadbalancer.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ resource "aws_lb_listener_rule" "forward_to_app" {
150150
priority = 50000
151151
action {
152152
type = "forward"
153-
target_group_arn = local.default_lb_target_group_arn
153+
target_group_arn = local.ecs_initial_lb_target_group
154154
}
155155
condition {
156156
path_pattern {

terraform/app/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,6 @@ variable "active_lb_target_group" {
257257
}
258258

259259
locals {
260-
default_lb_target_group_arn = var.active_lb_target_group == "green" ? aws_lb_target_group.green.arn : aws_lb_target_group.blue.arn
260+
ecs_initial_lb_target_group = var.active_lb_target_group == "green" ? aws_lb_target_group.green.arn : aws_lb_target_group.blue.arn
261261
ecs_sg_ids = [module.web_service.security_group_id, module.good_job_service.security_group_id]
262262
}

0 commit comments

Comments
 (0)