Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(AWS/EC2/EBS) Why does "Delete on Termination" default to true for root devices?

On Amazon EC2, when you use an EBS volume as the root device for an EC2 instance, the "Delete on Termination" flag defaults to true, meaning the volume will automatically be deleted when you destroy the instance.

What is the point of this?

If the primary benefit of using EBS over local instance storage is storage persistence independent of instance persistence, doesn't this completely defeat the purpose of that?

If you don't mind the root device being destroyed along with the instance, why not just use local instance storage which is cheaper and less effort to create/manage?

Relevant references:

  • http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html
  • http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html#storage-for-the-root-device
  • http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-lifecycle.html#lifecycle-differences
like image 525
odigity Avatar asked Jul 15 '14 19:07

odigity


1 Answers

You might want to just start/stop your instance without terminating it and recreating a new one. In this case, you don't want you data on your instance reverted to the initial AMI state. You can do this with an EBS backed volume, you can't with ephemeral storage. I know I frequently cycle instances when testing boot and shutdown scripts and pause them when I don't need to pay for unneeded cycles.

Here's a similar question on serverfault with the diffs between rebooting, start/stop, and terminating: https://serverfault.com/questions/315123/difference-between-rebooting-and-stop-starting-an-amazon-ec2-instance

I think for many it's common after terminating an instance you want the backed storage removed, not just hanging around. If you want to keep state without an instance, you can take a snapshot or create a new AMI from the running instance before termination.

like image 142
Ray Avatar answered Oct 02 '22 15:10

Ray