How to Find EC2 Instances Scheduled To Retire Soon

To avoid unexpected interruptions, it's a good practice to check to see if you have any EC2 instances scheduled to retire. Here are the steps for locating and handling these EC2 instances.

Patrick Londa
Author
Apr 27, 2022
 • 
5
 min read
Share this post

When Amazon Web Services (AWS) detects a failure within the underlying hardware supporting your EC2 instance, it schedules the instance for retirement. If you don’t take the right steps before AWS stops or terminates the instance, your organization risks losing important live services and data at an unexpected time.

While there are notifications issued by AWS, it’s important for your organization to have a process for responding and handling retiring EC2 instances. If you don’t act quickly, then these instances may become unreachable depending on the extent of degradation.

A key part of building an EC2 retirement process is being able to quickly locate all instances with upcoming retirements. It can be difficult to locate all of these instances if you are operating in multiple AWS regions because you will need to run these queries per region. There are tools like Blink that enable an automated method for locating EC2 instances across regions, but for the sake of this guide, we’ll walk you through the steps using the manual approach first.

Blink Automation: Ensure EC2 Instances Scheduled to Expire are Reviewed
AWS + Slack
Try This Automation

Locating EC2 Instances Set for Retirement

The primary account holder and operations contacts receive an email from AWS letting them know which instance ID will be retired and the retirement date. You can also look for any instances due for retirement on your Amazon EC2 console or the command line.

To find retiring EC2 instances from the command line, open a terminal and run the following command:

aws ec2  describe-instance-status

To identify retiring instances when you are reading the output, look for results that have events with “event.code” of “instance_retirement”.

If you start getting error messages when you run the above command, try updating to the latest version of the AWS CLI. Those using AWS Tools for Windows PowerShell can use the following command:

Get-EC2InstanceStatus

Validating if an EC2 Instance is Reachable

Now that you have a list of upcoming retirements, you should check if your instance is still reachable before the retirement date. First, connect to or ping your retiring EC2 instance to see if there’s a response. If it has already become unreachable, you can try stopping and restarting the instance. If it’s accessible, start planning a time and date to stop/start the EC2 instance to reduce any impacts.

Handling an EC2 Instance Retirement

For each EC2 instance scheduled for retirement, you will need to stop and restart it before the retirement date. That action moves the instance over to a more stable host. 

Here is some useful context to keep in mind before stopping your EC2 instance:

EBS-Backed Instance

If you are using an EBS-backed retiring EC2 instance, be aware that the host is already in a state that prohibits you from launching EC2 instances on that hardware. There’s no need to take further action after stopping and restarting the instance. AWS persists any information stored in EBS volumes, so you don’t need to worry about data loss.

An EBS-backed instance can end up stuck in a stopped stage. If that happens, try forcing the instance to stop through the AWS console or by using the AWS CLI, which can take up to 10 minutes to complete.

Instance Store Volume Attached

If you have data stored on an instance store volume, that won’t persist once you stop your instance. You can prevent data loss by first connecting to the EC2 instance scheduled for retirement via a Remote Desktop Protocol. Next, move the data kept on your instance store volume over to another attached EBS volume.

Find All Retired EC2 Instances Quickly Using Blink

This quick check for upcoming EC2 retirements can ensure you don’t encounter unexpected changes, but you might not remember to run it regularly.

With Blink, you can find all retiring EC2 instances using an automation like this one:

Blink Automation: Ensure EC2 Reserved Instances Scheduled for Expiration are Reviewed in AWS
Blink Automation: Ensure EC2 Reserved Instances Scheduled for Expiration are Reviewed in AWS

This automation is available in the Blink library. When it runs, it does the following steps:

  1. Checks for EC2 Reserved Instances schedule to expire within a certain number of days.
  2. Sends a report with the results to a specified email.

This simple automation is easy to customize. Run it on a schedule or send the report via Slack or Teams.

There are over 5K automations in the Blink library to choose from, or you can build your own to match your unique needs.

Get started with Blink today and see how easy automation can be.

Automate your security operations everywhere.

Blink is secure, decentralized, and cloud-native. 
Get modern cloud and security operations today.

Get a Demo