An ASG instance refresh fails with `Instance refresh failed: ... could not maintain the minimum healthy percentage`.
AdvancedTroubleshootingEC2, Auto Scaling and Load Balancing
Answer
Likely causes → New instances from the updated launch template never become healthy, so the refresh cannot replace more instances without dropping below MinHealthyPercentage. Typical reasons: a bad AMI, broken user data or a failing health check. A checkpoint or alarm-based rollback may also have stopped it.
Diagnose →
aws autoscaling describe-instance-refreshes --auto-scaling-group-name web-asg --max-records 1
aws autoscaling describe-scaling-activities --auto-scaling-group-name web-asg --max-items 10
aws elbv2 describe-target-health --target-group-arn <tg-arn> \
--query 'TargetHealthDescriptions[].[Target.Id,TargetHealth.State,TargetHealth.Reason]'
Fix →
- Roll back:
aws autoscaling rollback-instance-refresh --auto-scaling-group-name web-asg, or cancel it and fix the template - Debug one new instance (console output, cloud-init log), then start the refresh again with
--preferences '{"MinHealthyPercentage":90,"InstanceWarmup":300,"AutoRollback":true}'
Prevent → Turn on AutoRollback with CloudWatch alarms, use checkpoints for canary-style refreshes, and test AMIs in staging first.