From 6795acc9ebdc7cd421feddf0f96a7fb584591d98 Mon Sep 17 00:00:00 2001 From: Jon Chery Date: Tue, 28 Jul 2026 18:27:10 +0000 Subject: [PATCH] fix(alb): create_before_destroy on target group + depends_on on listener MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the ALB port changes (simple 80 → complex 443), terraform tries to replace the target group while the listener still references it, causing ResourceInUse. Added lifecycle { create_before_destroy = true } to the target group and depends_on = [aws_lb_target_group.this] to the listener so the new target group is created before the old one is destroyed. ---ci--- project: acdl phase: P59 milestone: v1.11 status: execute ---/ci--- --- modules/l1/alb/terraform/main.tf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/l1/alb/terraform/main.tf b/modules/l1/alb/terraform/main.tf index f17728b..98bb44b 100644 --- a/modules/l1/alb/terraform/main.tf +++ b/modules/l1/alb/terraform/main.tf @@ -11,6 +11,10 @@ resource "aws_lb_target_group" "this" { protocol = var.protocol vpc_id = var.vpc_id target_type = var.target_type + + lifecycle { + create_before_destroy = true + } } resource "aws_lb_listener" "this" { @@ -22,4 +26,6 @@ resource "aws_lb_listener" "this" { type = "forward" target_group_arn = aws_lb_target_group.this.arn } -} + + depends_on = [aws_lb_target_group.this] +} \ No newline at end of file