My Spot Instance was terminated. Can I recover it?
Last updated: 2019-10-30
I had an Amazon Elastic Compute Cloud (Amazon EC2) Spot Instance running, but the instance was terminated, and I’m concerned I might have lost data. Are there ways to recover my instance or the data stored on that instance?
With Amazon EC2 Spot Instance, you can bid on spare Amazon EC2 instances to reduce your compute costs. If the Spot price increases above your bid price, capacity is no longer available, or the spot request has constraints that can't be met, then the Spot Instance can be terminated. For more details about the reasons a Spot Instance can be interrupted, see How Spot Instances Work. Data that isn't backed up can be lost when instances are terminated, so it's important to be sure that your application is prepared for a Spot Instance interruption. If you have an application that can't be interrupted, we don't recommend Spot Instances. See Spot Use Cases for a list of best-suited use cases and workload types.
If you have a Spot Instance that was recently terminated or interrupted, and you’re concerned that data might have been lost, here are some places to check for your data:
- Did you configure your Spot Instances to leave Amazon EBS volumes behind if the instance is terminated? By configuring the Spot Instance to leave Amazon EBS volumes behind if the instance is terminated, you can attach the volume to another instance and attempt to recover data stored on the volume. When creating a Spot Instance request, clear the Delete check box for Amazon EBS volumes you want to be kept if the instance is terminated. If you attached a volume to your Spot Instance before it was terminated or interrupted, the data you’re looking for might be stored on the volume. Open the Amazon EC2 Console, and then select Volumes. Look for any unattached volumes that have a State of available. These volumes can be attached to another instance. For instructions on attaching a volume to a new instance, see Attaching an Amazon EBS Volume to an Instance.
- Did you take regular snapshots of any volumes attached to your Spot Instance? Snapshots that are normally used as backups for Amazon EBS volumes might contain the data you’re looking for. Open the Amazon EC2 Console, and then select Snapshots. Look for any snapshots of volumes that were attached to your Spot Instance. For more information, see Restoring an Amazon EBS Volume from a Snapshot.
- Was the data added or backed up to another source? Common output sources for workflows that run through Spot Instances include Amazon Simple Storage Service (Amazon S3), Amazon DynamoDB, and Amazon Relational Database Service (Amazon RDS). If you set your Spot Instance to send output to one of these services, check those services for the data you’re looking for.
In the future, it’s a best practice to prepare for a Spot Instance’s termination ahead of time. For example, you can specify Amazon EC2 to stop or hibernate your Spot Instances rather than terminate when they are interrupted. For more information about how to effectively prepare for a Spot Instance’s eventual termination, see Spot Instance Interruptions.