How can I configure my EC2 Spot Instances so that the root EBS volume won’t be deleted when I terminate the instance?

2 minute read
0

I want to configure my Amazon Elastic Compute Cloud (Amazon EC2) Spot Instances so that the root Amazon Elastic Block Store (Amazon EBS) volume isn't deleted when I terminate the instance.

Resolution

By default, when EC2 Spot Instances are terminated, all EBS volumes attached to that instance are deleted because the DeleteOnTermination attribute is set to true.

To change the DeleteOnTermination attribute for a new Spot request

  1. Open the Amazon EC2 console, and then choose Spot Requests from the navigation pane.
  2. Choose Request Spot Instances.
  3. Choose an Availability Zone, and then choose Next.
  4. In EBS volumes, clear Delete.

After you clear the Delete box, finish creating your Spot request. Any new instances that are launched when this Spot request is fulfilled will have DeleteOnTermination set to false.

Note: EBS volumes with DeleteOnTermination set to false incur charges and remain in your EBS volume console. You must manually delete the volume. For more information, see Amazon EBS pricing.

To change the DeleteOnTermination attribute for a running Spot Instance

Use the modify-instance-attribute command in the AWS Command Line Interface (AWS CLI) to configure the root EBS volume to persist on termination.


Related information

Spot Instances

AWS OFFICIAL
AWS OFFICIALUpdated a year ago