Interview Prep/AWS/EC2, Auto Scaling and Load Balancing

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 →

  1. Roll back: aws autoscaling rollback-instance-refresh --auto-scaling-group-name web-asg, or cancel it and fix the template
  2. 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.

aws All AWS questions Roadmap: AWS core services

More on EC2, Auto Scaling and Load Balancing