SAA-C03Chapter 77 of 189Objective 2.1

ASG Termination Policies

This chapter covers Auto Scaling Group (ASG) termination policies, a critical topic for the SAA-C03 exam. You will learn the different policies, their order of evaluation, and how they interact with health checks and lifecycle hooks. Understanding termination policies is essential for designing resilient and cost-optimized architectures. Approximately 5-10% of exam questions touch on ASG termination behavior, often in the context of high availability and fault tolerance.

25 min read
Intermediate
Updated May 31, 2026

Factory Assembly Line with Multiple Exit Doors

Imagine a large factory assembly line that produces identical widgets. The factory has multiple exit doors (Availability Zones) through which finished widgets leave. A manager decides which door each widget uses based on a set of rules (termination policies). The simplest rule is to use the door with the most widgets currently waiting (Oldest Launch Template), ensuring that older batches are cleared first. Another rule is to use the door that has the fewest widgets overall (AllocationStrategy – balanced across doors). If a door is producing defective widgets (unhealthy instances), the manager can prioritize removing those defective ones first (HealthCheckGracePeriod and suspend processes). The factory also has a policy to avoid closing a door that is already heavily loaded (AZRebalance). This ensures that the factory maintains balanced output and quickly removes faulty or outdated products.

How It Actually Works

What is an ASG Termination Policy?

An Auto Scaling Group (ASG) termination policy determines which EC2 instance is terminated when the group scales in (reduces capacity) or when an instance is marked unhealthy. The policy is applied during scale-in events triggered by scaling policies (e.g., target tracking, step scaling) or manual adjustments. The default termination policy is designed to distribute instances evenly across Availability Zones (AZs) and to terminate instances that are least likely to disrupt applications.

Why Termination Policies Matter

Termination policies directly impact application availability, cost, and performance. A poorly chosen policy can lead to:

Imbalanced distribution across AZs, increasing risk of failure if one AZ goes down.

Terminating instances that are running critical workloads or have long-running jobs.

Higher costs if instances with reserved instances or savings plans are terminated unnecessarily.

The SAA-C03 exam tests your ability to select the correct termination policy for a given scenario, often combined with other ASG features like lifecycle hooks, health checks, and mixed instances policies.

How Termination Policies Work Internally

When a scale-in event occurs, the ASG follows these steps: 1. Determine which AZ(s) to terminate from: The ASG first checks the AZ rebalancing logic. If the group is not balanced (i.e., one AZ has significantly more instances than others), it will terminate instances from the AZ with the most instances to restore balance. If all AZs are balanced, it proceeds to the next step. 2. Apply the termination policy: The ASG evaluates the configured termination policy (or the default if none is specified) to select an instance to terminate. The policy is applied in a specific order, as described below. 3. Consider lifecycle hooks: If a lifecycle hook for termination (autoscaling:EC2_INSTANCE_TERMINATING) is configured, the ASG waits for the hook to complete (or timeout) before proceeding. The default timeout is 3600 seconds (1 hour), configurable up to 48 hours. 4. Execute termination: The ASG calls the EC2 API to terminate the selected instance. The instance enters the shutting-down and then terminated state.

Default Termination Policy

The default termination policy is designed to:

Select the AZ with the most instances and the oldest launch configuration/template.

If multiple instances are equally old, select the one closest to the next billing hour (to minimize cost).

The exact algorithm: 1. Select the AZ with the most instances (if the group spans multiple AZs). If multiple AZs have the same count, the ASG randomly picks one among them. 2. Within that AZ, select instances with the oldest launch configuration/template (i.e., the earliest launch time). If multiple instances have the same launch time, select the one closest to the next billing hour. 3. If still tied, select randomly.

Available Termination Policies

You can configure one of the following policies directly on the ASG:

OldestLaunchConfiguration: Terminates the instance with the oldest launch configuration (or launch template). This is useful when you want to phase out older configurations gradually.

OldestLaunchTemplate: Same as above but specifically for launch templates.

ClosestToNextInstanceHour: Terminates the instance that is closest to the next billing hour (i.e., has been running the longest since the last full hour). This minimizes wasted cost if you are paying per hour.

NewestInstance: Terminates the newest instance. This can be useful if you want to test new configurations on a small number of instances and quickly revert.

Default: Uses the default algorithm described above.

AllocationStrategy: This is used in conjunction with Spot Instances and is not a termination policy per se, but it affects which instances are terminated. The allocation strategy (lowest-price, capacity-optimized, etc.) is used when launching instances, but termination policies still apply.

Order of Evaluation

The ASG evaluates policies in a specific order. If you specify multiple policies (up to 20), they are evaluated in sequence. The first policy that can select a unique instance wins. If no unique instance is selected, the next policy is applied. This allows you to create complex termination logic.

For example, if you set policies to: OldestLaunchTemplate, ClosestToNextInstanceHour, the ASG will first try to find an instance with the oldest launch template. If multiple instances have the same launch template age (e.g., all were launched with the same template), it will then apply the next policy to break the tie.

Interaction with Health Checks

ASG uses health checks to determine if an instance is healthy. If an instance fails a health check (e.g., EC2 status check, ELB health check), the ASG marks it as unhealthy and will terminate and replace it. The termination policy is still applied when the ASG decides which unhealthy instance to terminate, but typically the unhealthy instance is the only candidate. However, if multiple instances are unhealthy, the policy is used to choose among them.

Lifecycle Hooks and Termination

Lifecycle hooks can pause the termination process. When a lifecycle hook is in the autoscaling:EC2_INSTANCE_TERMINATING transition, the instance remains in the Terminating:Wait state until the hook completes or times out. This allows you to perform custom actions (e.g., backup logs, drain connections) before termination. The default timeout is 3600 seconds, but you can adjust it up to 48 hours.

Standby Instances

You can put an instance in standby state. Instances in standby are not considered for termination during scale-in events. They also do not count as part of the desired capacity, so you can manually manage them without triggering scaling actions.

Suspend Processes

You can suspend the Terminate process on the ASG, which prevents any terminations. This is useful during maintenance windows or when you want to manually control scaling.

Example: Default Policy in a Multi-AZ ASG

Consider an ASG with: - 6 instances across 3 AZs: AZ-a has 3, AZ-b has 2, AZ-c has 1. - All instances use the same launch template. - A scale-in event reduces desired capacity by 1.

The ASG will: 1. Select AZ-a (the AZ with the most instances). 2. Among the 3 instances in AZ-a, select the one with the oldest launch template (all same), then the one closest to the next billing hour. 3. Terminate that instance.

If the group was balanced (2 each), the ASG would randomly pick an AZ (or use the next policy if configured) and then apply the same logic.

Configuring Termination Policies

You can set termination policies via the AWS Management Console, CLI, or SDK. For example, using the AWS CLI:

aws autoscaling update-auto-scaling-group \
    --auto-scaling-group-name my-asg \
    --termination-policies "OldestLaunchTemplate" "ClosestToNextInstanceHour"

You can also specify policies during creation:

aws autoscaling create-auto-scaling-group \
    --auto-scaling-group-name my-asg \
    --launch-template LaunchTemplateName=my-template \
    --min-size 1 --max-size 5 --desired-capacity 2 \
    --vpc-zone-identifier subnet-abc,subnet-def \
    --termination-policies "Default"

Verification

To see which termination policy is in effect:

aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names my-asg

Look for the TerminationPolicies field in the output.

Interaction with Mixed Instances Policy

When using a mixed instances policy (e.g., combining On-Demand and Spot Instances), the termination policy applies uniformly across all instances. However, the ASG may prioritize terminating Spot Instances over On-Demand if the Spot allocation strategy requires it (e.g., if using capacity-optimized and Spot capacity is needed elsewhere). But the termination policy itself does not differentiate by instance type.

Key Values and Defaults

Default termination policy: Default (as described above).

Maximum number of termination policies: 20 (in a list).

Lifecycle hook default timeout: 3600 seconds (1 hour), max 48 hours.

Health check grace period: 300 seconds by default, configurable.

Instance warm-up: 300 seconds by default when using scaling policies.

Common Misconfigurations

Setting NewestInstance policy when you want to preserve recent changes – this will terminate the newest instances first, which may be running updated software.

Not considering AZ rebalancing – the default policy already balances AZs, but if you set a custom policy that doesn't consider AZs, you may end up with an imbalanced group.

Forgetting that lifecycle hooks can delay termination – if not handled properly, instances may remain in Terminating:Wait indefinitely (until timeout).

Walk-Through

1

Scale-in event triggered

An Auto Scaling group receives a scale-in request, either from a scaling policy (e.g., target tracking, step scaling) or a manual adjustment. The group's desired capacity is reduced by one or more instances. The ASG begins the termination process by first determining which Availability Zone (AZ) to terminate from, based on the current distribution of instances across AZs. If the group is unbalanced (one AZ has significantly more instances), the ASG selects the AZ with the most instances to restore balance. If all AZs are balanced, it randomly selects an AZ among them.

2

Apply termination policy

Within the selected AZ, the ASG evaluates the configured termination policies in order. If multiple policies are specified (up to 20), it applies the first one that can uniquely identify an instance to terminate. For example, if the first policy is `OldestLaunchTemplate`, the ASG lists instances in that AZ, groups them by launch template version, and selects the group with the oldest launch template. If that group contains a single instance, that instance is chosen. If multiple instances share the same oldest launch template, the ASG moves to the next policy (e.g., `ClosestToNextInstanceHour`) to break the tie. If no policy can uniquely identify an instance, the default algorithm is used as a fallback.

3

Check lifecycle hooks

Before terminating the selected instance, the ASG checks if any lifecycle hooks are configured for the `autoscaling:EC2_INSTANCE_TERMINATING` transition. If a hook exists, the instance enters the `Terminating:Wait` state. The ASG waits for the hook to complete (either by calling `complete-lifecycle-action` or after the timeout expires). The default timeout is 3600 seconds (1 hour), but can be configured up to 48 hours. During this wait, the instance remains running and can perform custom actions like draining connections or backing up data. If multiple hooks are configured, they are executed in sequence.

4

Execute termination

Once lifecycle hooks (if any) are completed or timed out, the ASG calls the EC2 API to terminate the instance. The instance transitions from `Terminating:Wait` to `Terminating:Proceed`, and then to `shutting-down` and `terminated`. The ASG decrements the desired capacity count. If the instance was part of a load balancer target group, it is deregistered. Any attached EBS volumes are detached (unless `DeleteOnTermination` is set to false). The termination is logged in CloudTrail and can trigger CloudWatch events or SNS notifications.

5

AZ rebalancing (if applicable)

After termination, the ASG checks the distribution of instances across AZs. If the group is now imbalanced (e.g., one AZ has fewer instances than others), the ASG may launch new instances in the underutilized AZ to rebalance. This is done by the `AZRebalance` process, which is enabled by default. However, if the scale-in event was triggered by a policy that reduces desired capacity, rebalancing may not occur until the next scale-out event. The ASG will not launch instances solely for rebalancing if it would exceed the max size. Rebalancing helps maintain high availability by ensuring instances are evenly distributed.

What This Looks Like on the Job

In a large e-commerce platform, ASG termination policies are critical for maintaining application stability during deployments. For example, when a new version of the application is released via a rolling update, the ASG might use the OldestLaunchTemplate policy to gradually replace instances running the old version. This ensures that only instances with the old template are terminated first, minimizing the number of instances running outdated code. However, if the new version has a bug, the team might want to quickly roll back by terminating the newest instances. In that case, they would temporarily switch the termination policy to NewestInstance.

Another scenario involves cost optimization. A company runs a mix of On-Demand and Spot Instances in the same ASG. They want to ensure that Spot Instances are terminated before On-Demand when scaling in, to save costs. However, the termination policy itself does not distinguish between instance types. To achieve this, they use a lifecycle hook that checks the instance's lifecycle (Spot vs. On-Demand) and, if it's On-Demand, puts it back into service or delays termination. Alternatively, they could use two separate ASGs—one for On-Demand and one for Spot—each with its own termination policy.

A common misconfiguration is setting the termination policy to ClosestToNextInstanceHour without understanding the billing implications. This policy terminates instances that are closest to the next billing hour, meaning they have been running the longest since the last full hour. While this minimizes wasted partial hours, it can cause frequent terminations of instances that are near the end of their hour, leading to unnecessary churn. In practice, this policy is rarely used unless you have very short-lived workloads.

In production, many teams use the default termination policy because it automatically balances across AZs and considers launch template age. However, they often combine it with lifecycle hooks to gracefully shut down applications. For instance, a web application might use a lifecycle hook to drain connections from the load balancer before termination, preventing dropped requests. The hook waits for the application to finish processing in-flight requests, up to a configurable timeout (e.g., 300 seconds). If the timeout expires, the instance is forcibly terminated.

When misconfigured, termination policies can cause availability issues. For example, if you set NewestInstance and a scale-in event occurs during a blue/green deployment, you might terminate all the new instances, defeating the purpose of the deployment. Similarly, if you forget to configure a termination policy and rely on the default, but your instances have different launch templates (e.g., from a rolling update), the default will terminate the oldest ones, which might be the ones you want to keep. Always test termination behavior in a staging environment before applying to production.

How SAA-C03 Actually Tests This

The SAA-C03 exam tests termination policies under Objective 2.1 (Resilient Architectures) and often in conjunction with other ASG features. You should know:

Objective 2.1: Design scalable and loosely coupled architectures. Termination policies affect how scaling events impact application availability.

Common exam scenarios:

You need to terminate instances with the oldest launch configuration to phase out an old AMI.

You need to minimize cost by terminating instances closest to the next billing hour.

You need to preserve instances that are running critical jobs (use lifecycle hooks or standby state).

Trap answers:

Choosing OldestInstance (not a valid policy; the correct name is OldestLaunchConfiguration or OldestLaunchTemplate).

Thinking that ClosestToNextInstanceHour terminates instances that have been running the shortest time (it's the opposite).

Assuming that the termination policy can be used to prioritize Spot instances over On-Demand (it cannot; you need other mechanisms).

Numbers to memorize:

Maximum termination policies: 20.

Lifecycle hook default timeout: 3600 seconds (1 hour), max 48 hours.

Health check grace period default: 300 seconds.

Edge cases:

If you suspend the Terminate process, no instances can be terminated regardless of policy.

If an instance is in standby, it is not considered for termination.

When using a mixed instances policy, termination policies apply uniformly; you cannot specify different policies for On-Demand vs. Spot.

How to eliminate wrong answers:

If the question mentions "cost optimization" and "partial hours", think of ClosestToNextInstanceHour.

If the question mentions "rolling update" or "phasing out old configurations", think of OldestLaunchConfiguration or OldestLaunchTemplate.

If the question mentions "balanced across AZs", the default policy already does that, but you might need to ensure no custom policy overrides it.

If the question mentions "avoid terminating instances that are processing data", think of lifecycle hooks or standby, not a termination policy change.

Remember: The termination policy only affects which instance is chosen for termination when a scale-in event occurs. It does not affect health check replacements (though the same policy applies). Also, the default policy is almost always the safest choice unless you have a specific requirement.

Key Takeaways

The default termination policy balances across AZs and selects the oldest launch configuration/template within the chosen AZ.

Valid termination policies: Default, OldestLaunchConfiguration, OldestLaunchTemplate, ClosestToNextInstanceHour, NewestInstance.

You can specify up to 20 termination policies in a list; they are evaluated in order until one uniquely identifies an instance.

Lifecycle hooks for termination have a default timeout of 3600 seconds (1 hour), configurable up to 48 hours.

Instances in standby state are not considered for termination.

The `Terminate` process can be suspended to prevent any terminations.

Termination policies do not distinguish between On-Demand and Spot Instances.

The `ClosestToNextInstanceHour` policy terminates instances that have been running the longest since the last full hour, minimizing wasted partial hours.

Health check grace period default is 300 seconds.

AZ rebalancing occurs after termination if the group becomes imbalanced, but only if it does not exceed max size.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

OldestLaunchTemplate

Terminates instances with the oldest launch template.

Useful for rolling updates to gradually replace old instances.

Ensures that instances with outdated configurations are removed first.

May cause termination of long-running instances if they are based on old templates.

Default behavior when combined with AZ balancing.

NewestInstance

Terminates the most recently launched instances.

Useful for quickly rolling back a bad deployment.

Preserves older, stable instances.

Can lead to loss of recent changes if not intended.

Not recommended for normal operations as it disrupts new instances.

Watch Out for These

Mistake

The termination policy `OldestInstance` is a valid policy.

Correct

There is no `OldestInstance` policy. The correct names are `OldestLaunchConfiguration` and `OldestLaunchTemplate`. The exam may try to trick you with `OldestInstance`.

Mistake

The `ClosestToNextInstanceHour` policy terminates the instance that has been running the shortest time.

Correct

It terminates the instance that is closest to the next billing hour, meaning it has been running the longest since the last full hour. This minimizes wasted partial hours.

Mistake

Termination policies can prioritize Spot Instances over On-Demand.

Correct

Termination policies apply uniformly to all instances regardless of purchase option. To prioritize Spot termination, you need separate ASGs or lifecycle hooks.

Mistake

The default termination policy always terminates the oldest instance.

Correct

The default policy first balances across AZs, then selects the oldest launch configuration/template within the selected AZ. It does not simply pick the globally oldest instance.

Mistake

Lifecycle hooks can prevent termination indefinitely.

Correct

Lifecycle hooks have a timeout (default 3600 seconds, max 48 hours). If the hook does not complete within the timeout, the ASG proceeds with termination. You can extend the timeout but it is not indefinite.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the default termination policy for an Auto Scaling group?

The default termination policy is designed to first select the Availability Zone (AZ) with the most instances. If multiple AZs have the same count, it randomly picks one. Within that AZ, it selects instances with the oldest launch configuration or launch template. If multiple instances have the same age, it selects the one closest to the next billing hour. If still tied, it selects randomly. This policy balances instances across AZs and phases out older configurations.

Can I use termination policies to ensure Spot Instances are terminated before On-Demand?

No, termination policies apply uniformly to all instances regardless of purchase option. To prioritize termination of Spot Instances, you would need to use separate Auto Scaling groups for On-Demand and Spot, or implement a lifecycle hook that checks the instance's lifecycle and manually terminates Spot instances first.

What happens if a lifecycle hook for termination times out?

If a lifecycle hook times out (default 3600 seconds, max 48 hours), the ASG proceeds with the termination. The instance transitions from `Terminating:Wait` to `Terminating:Proceed` and is then terminated. You can also explicitly complete the hook using the `complete-lifecycle-action` API call to finish early.

How do I prevent an instance from being terminated during a scale-in event?

You can put the instance in standby state. Instances in standby are not considered for termination and are not counted toward desired capacity. Alternatively, you can suspend the `Terminate` process on the ASG, which prevents all terminations until the process is resumed.

What is the difference between `OldestLaunchConfiguration` and `OldestLaunchTemplate`?

Both policies terminate the instance with the oldest launch configuration or launch template, respectively. The difference is the source: `OldestLaunchConfiguration` applies to groups using launch configurations (legacy), while `OldestLaunchTemplate` applies to groups using launch templates (recommended). If your ASG uses a launch template, use `OldestLaunchTemplate`.

Can I specify multiple termination policies? How are they evaluated?

Yes, you can specify up to 20 termination policies in a list. They are evaluated in order. The first policy that can uniquely identify an instance to terminate is applied. If the first policy results in multiple candidates (e.g., multiple instances with the same oldest launch template), the next policy is used to break the tie. If no policy can uniquely identify an instance, the default algorithm is used as a fallback.

Does the termination policy affect health check replacements?

Yes, when an instance is marked unhealthy and the ASG decides to replace it, the same termination policy is used to select which unhealthy instance to terminate. However, typically only one instance is unhealthy at a time, so the policy may not come into play unless multiple instances are unhealthy.

Terms Worth Knowing

Ready to put this to the test?

You've just covered ASG Termination Policies — now see how well it sticks with free SAA-C03 practice questions. Full explanations included, no account needed.

Done with this chapter?