I created a new EC2 instance, but when I terminated the instance, the EBS volume was deleted. I want to keep the attached EBS volumes when I terminate an instance. How can I do that?
When an instance is terminated, Amazon Elastic Compute Cloud (Amazon EC2) uses the value of the DeleteOnTermination attribute for each attached EBS volume to determine whether to preserve or delete the volume when the instance is terminated. By default, the DeleteOnTermination attribute for the root volume of an instance is set to true, but it is set to false for all other volume types.
To preserve the root volume when an instance is terminated, change the DeleteOnTermination attribute for the root volume to false.
When you launch a new instance, you can set DeleteOnTermination to False by following the instructions at Changing the Root Volume to Persist at Launch Using the Console.
If the instance is already running, you can set DeleteOnTermination to False by following the instructions at Changing the Root Volume of a Running Instance to Persist Using the Command Line.