On Tue, Aug 7, 2012 at 6:09 AM, Mark Allen via RT
<bug-Net-Amazon-EC2@rt.cpan.org> wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=78779 >
>
> On Sat Aug 04 20:27:08 2012, andrew@illywhacker.net wrote:
>> Hi again Mark
>>
>> I've found a bug in
>>
>> * Distribution: Net::Amazon::EC2
>> * Version: 0.18
>>
>> The problem is that it's imposing constraints which are too strict on
>> the parameters of
>> modify_instance_attribute and this is preventing a call like:
>>
>> + $ec2->modify_instance_attribute(
>> + InstanceId => $self->instanceId,
>> + Attribute => 'blockDeviceMapping',
>> + 'BlockDeviceMapping.1.DeviceName' => $aws_mountpoint,
>> + 'BlockDeviceMapping.1.Ebs.DeleteOnTermination' => 'true',
>> + );
>> +
>>
>> which I need to call when I mount an ebs after instantiating, but want
>> the ebs volume to be deleted when I terminate the instance.
>>
>> Here's my hack which enabled this call to work.
>>
>> $ diff /usr/local/share/perl/5.14.2/Net/Amazon/EC2.pm
>> /usr/local/share/perl/5.14.2/Net/Amazon/EC2.pm.FIXED
>> sub modify_instance_attribute {
>> ...
>> < my %args = validate( @_, {
>> < InstanceId => { type => SCALAR },
>> < Attribute => { type => SCALAR },
>> < Value => { type => SCALAR },
>> < });
>> ---
>> > #my %args = validate( @_, {
>> > #InstanceId => { type => SCALAR },
>> > #Attribute => { type => SCALAR },
>> > #Value => { type => SCALAR },
>> > #});
>> >
>> > my %args = (@_);
>>
>> kind regards
>>
>> Andrew
>
> The "right" way to do this, according to the docs would be to make two separate calls on the
> same instance. I'm trying to think of a better interface for this method, and it seems like
> passing in a data structure would be a good idea, as in
>
> { 'BlockDeviceMapping' => {
> DeviceName => $aws_mountpoint,
> Ebs.DeleteOnTermination => 'true',
> }
> }
>
> but there's no good way I can see to make that backwards compatible.
>
> Any further thoughts about an interface that would meet your needs while still allowing
> validation of parameters?
Hi Mark
When you say the right way to do this would be to make two separate
calls, I think you're referring to this page
http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html
which says 'You can specify only one attribute at a time'. However, I
think this is a misunderstanding. The Attribute is
'blockDeviceMapping' and the single "Value" is {
DeviceName => $aws_mountpoint,
Ebs.DeleteOnTermination => 'true',
}
If you were to allow the Value the type SCALAR | HASHREF then you
could interpret
$ec2->modify_instance_attribute(
InstanceId => 'i-12345',
Attribute => 'blockDeviceMapping',
Value => 'foo',
);
as
InstanceId=i-12345&Attribute=blockDeviceMapping&Value=foo
while interpreting
$ec2->modify_instance_attribute(
InstanceId => 'i-12345',
Attribute => 'blockDeviceMapping',
Value => {
'BlockDeviceMapping.1.DeviceName' => '/dev/sdf1',
'BlockDeviceMapping.1.Ebs.DeleteOnTermination' => 'true',
}
);
as
InstanceId=i-12345&Attribute=blockDeviceMapping&BlockDeviceMapping.1.DeviceName=/dev/sdf1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true
omitting the key 'Value'.
How does that sound?
Andrew