How can I prevent my Amazon EBS volumes from being deleted when I terminate Amazon EC2 instances?
Last updated: 2020-11-25
When I terminate an Amazon Elastic Compute Cloud (Amazon EC2) instance, the Amazon Elastic Block Store (Amazon EBS) volume is deleted. How can I preserve the attached Amazon EBS volumes when an instance terminates?
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, and 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: 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 .
You can set the DeleteOnTermination attribute to False when you launch a new instance.
For instructions using the Amazon EC2 console, see Changing the root volume to persist at launch using the console.
To use the AWS CLI or AWS Tools for Windows PowerShell, see Changing the root volume to persist at launch using the command line.
If the instance is already running, you can set DeleteOnTermination to False using the command line.