Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EC2 volume: how do I set it so that it WILL delete on termination?

I have an EC2 instance that I'd like to take a snapshot of, to use as an AMI for future spot instances. Because of the way I created volume for this instance, it is currently set to not delete upon termination.
I want it to delete on termination, so that I can use it for spot instances and not have residual volumes hanging around needing manual deletion.

I've combed AWS manual, stack exchange, google, etc and I can only find references to a 'delete on termination' flag, but no explanation of how to use it.

like image 294
Dan Avatar asked Nov 15 '11 15:11

Dan


2 Answers

Taking on what @akshar wrote, you can have it all in the same line, without the need for an additional json file:

 aws ec2 modify-instance-attribute --instance-id i-123abc45 --block-device-mappings "[{\"DeviceName\": \"/dev/sdf\",\"Ebs\":{\"DeleteOnTermination\":true}}]"

where /dev/sdf is the mount point in your instance

like image 124
Doron Avatar answered Oct 21 '22 07:10

Doron


enable delete on termination, for example http://itsecureadmin.com/2011/06/aws-instance-ebs-volume-delete-on-termination/

like image 33
FigmentEngine Avatar answered Oct 21 '22 07:10

FigmentEngine