Course contentsShow
← Cloud and Infrastructure
Lesson 319 of 2,9896. Auto ScalingFree lesson

ASG Termination Policies

Understanding default and custom termination policies that control which instances are removed first.

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:

  1. Availability Zone balancing - Terminate from the AZ with the most instances
  2. Oldest launch template - Remove instances using outdated configurations first
  3. Billing hour proximity - Choose instances closest to their next billing hour (cost optimization)
  4. 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 first
  • NewestInstance - Remove the newest (useful for testing rollbacks)
  • OldestLaunchConfiguration - Target outdated configurations
  • ClosestToNextInstanceHour - Minimize wasted billing time
  • Default - 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.