How can I prevent my Amazon EBS volumes from being deleted when I terminate Amazon EC2 instances?

2 minute read

When I terminate an Amazon Elastic Compute Cloud (Amazon EC2) instance, the Amazon Elastic Block Store (Amazon EBS) volume is deleted.


When an instance terminates, the value of the DeleteOnTermination attribute for each attached EBS volume determines whether to preserve or delete the volume. By default, the DeleteOnTermination attribute is set to True for the root volume. It is set to False for all other volume types.

To preserve the root volume when an instance terminates, change the DeleteOnTermination attribute for the root volume to False.

Note: You don't incur billing costs for changing these values. However, charges are still incurred for the resources on EBS volumes that you choose to preserve, according to EBS pricing.

If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.

New instances

You can set the DeleteOnTermination attribute to False when you launch a new instance.

For instructions using the Amazon EC2 console, see Change the root volume to persist at launch using the console.

To use the AWS CLI or AWS Tools for Windows PowerShell, see Change the root volume to persist at launch using the command line.

Running instances

If the instance is already running, you can set DeleteOnTermination to False using the command line.

Related information

Amazon EBS volumes

What happens when you terminate an instance

AWS OFFICIALUpdated 2 years ago