ASG Termination Policies
What You'll Learn
You'll understand how AWS Auto Scaling Groups decide which instances to remove when scaling in, using default and custom termination policies.
The Problem: Which Instance Goes First?
When your ASG scales in (reduces capacity), it needs to choose which instances to terminate. Without rules, this decision would be arbitrary and potentially disruptive. Termination policies provide the logic that determines the order in which instances are evaluated for removal.
Think of it like a teacher dismissing students from class early—should it be first-come-first-served, those sitting closest to the door, or those with the least homework remaining?
Default Termination Policy
AWS uses a multi-step default policy:
- Availability Zone balancing - Terminate from the AZ with the most instances
- Oldest launch template - Remove instances using outdated configurations first
- Billing hour proximity - Choose instances closest to their next billing hour (cost optimization)
- Random selection - If still tied, pick randomly
This ensures balanced distribution across AZs while preferring older configurations.
Custom Termination Policies
You can override the default with policies like:
OldestInstance- Remove the oldest instance firstNewestInstance- Remove the newest (useful for testing rollbacks)OldestLaunchConfiguration- Target outdated configurationsClosestToNextInstanceHour- Minimize wasted billing timeDefault- Use the standard multi-step approach
You can specify multiple policies in priority order.
Practical Impact
If you're deploying a new application version via launch template update, using OldestLaunchConfiguration ensures old instances are replaced first during scale-in events, gradually modernizing your fleet.
Key Takeaway: Termination policies give you control over which instances are removed during scale-in, balancing concerns like cost optimization, version management, and availability zone distribution.