From 1e4e2910cb34b0246a528d44f6a9b25a8887e552 Mon Sep 17 00:00:00 2001 From: Irving Popovetsky Date: Mon, 23 Nov 2026 08:40:23 -0800 Subject: [PATCH] Roll ECS instances automatically when the AMI changes Add a Rolling instance_refresh to the ECS Auto Scaling group. A new ECS-optimized AMI from SSM bumps the launch template version, and the refresh replaces instances one at a time. min 100 / max 150 makes AWS launch the replacement before it terminates the old instance. Co-Authored-By: Claude Opus 5.5 --- terraform/asg.tf | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/terraform/asg.tf b/terraform/asg.tf index ffe6b29..6a88458 100644 --- a/terraform/asg.tf +++ b/terraform/asg.tf @@ -74,6 +74,17 @@ module "autoscaling" { # ] } + # A new AMI bumps the launch template version; roll instances onto it automatically + instance_refresh = { + strategy = "Rolling" + preferences = { + min_healthy_percentage = 100 + max_healthy_percentage = 150 + instance_warmup = 300 + skip_matching = true + } + } + image_id = local.ecs_ami_id user_data = base64encode(local.user_data) ignore_desired_capacity_changes = true