flexera-public / right_aws

RightScale Amazon Web Services Ruby Gems
MIT License
451 stars 175 forks source link

Add support for setting DeleteOnTermination flag for EBS Volumes #134

Closed ajkerr closed 2 years ago

ajkerr commented 12 years ago

The ModifyInstanceAttribute API allows you to set the DeleteOnTerminiation flag for EBS volumes associated with an EC2 instance. The current modify_instance_attribute method does not support the syntax required for this method.

Making things more difficult is that fact that the AWS documentation is incorrect. I looked at the ModifyInstanceAttributeRequestMarshaller class in the AWS Java SDK to figure out what the syntax is supposed to look like. Because the syntax is so different from other attributes, I suggest adding a new method to RightAws::Ec2 as follows:

# The existing modify_instance_attribute method does not work properly for modifying block device attributes.
#
# ec2.modify_block_device_delete_on_termination_attribute(instance, "/dev/sdi", "true") #=> true
#
def modify_block_device_delete_on_termination_attribute(instance_id, device_name, delete_on_termination)
    request_hash = {'InstanceId' => instance_id}
    request_hash["BlockDeviceMapping.1.DeviceName"] = device_name
    request_hash["BlockDeviceMapping.1.Ebs.DeleteOnTermination"] = delete_on_termination
    link = generate_request('ModifyInstanceAttribute', request_hash)
    request_info(link, RightBoolResponseParser.new(:logger => @logger))
rescue Exception
    on_exception
end
loopj commented 11 years ago

Any update on this?

gerbercj commented 11 years ago

I also have a need to set the DeleteOnTermination flag. Any updates would be appreciated.

ghost commented 11 years ago

I agree. Updates?