goamz icon indicating copy to clipboard operation
goamz copied to clipboard

Can't set EBS DeleteOnTermination to false

Open comron opened this issue 10 years ago • 1 comments

While using packer, I noticed that my block devices that were marked with "delete_on_termination: false" were still being deleted on termination on EC2. I believe the problem is here in goamz, where in "addBlockDeviceParams" in "ec2.go" the request is built up with the following:

if k.DeleteOnTermination {
    params[prefix+"Ebs.DeleteOnTermination"] = "true"
}

This makes sense if the default for DeleteOnTermination was false, but according to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html#preserving-volumes-on-termination

By default, we do the following: ... Delete the volumes that you attach to your instance at launch, including the root device volume, when you terminate the instance ...

So, unless I'm mistaken, it seems there is no way to set DeleteOnTermination to false.

comron avatar Jun 05 '14 18:06 comron

This is a common pattern throughout the library, and you're correct. The same issue exists in the ModifyInstance function for a few parameters - one of them, SourceDestCheck, has an additional flag SetSourceDestCheck, which it uses to figure out whether it should set the flag or not... Quite odd.

deoxxa avatar Aug 09 '14 11:08 deoxxa