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.
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:
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:
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:
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.
If you create a free Blink account, you can use pre-built automations to schedule checks like this one so you can build it into your regular practice.
Get started and create your free Blink account today.