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
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: