Skip Menu |

This queue is for tickets about the Net-Amazon-EC2 CPAN distribution.

Report information
The Basics
Id: 78779
Status: resolved
Priority: 0/
Queue: Net-Amazon-EC2

People
Owner: Nobody in particular
Requestors: andrew [...] illywhacker.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: modify_instance_attribute
Date: Sun, 5 Aug 2012 01:26:57 +0100
To: bug-Net-Amazon-EC2 [...] rt.cpan.org, Andrew Solomon <andrew [...] illywhacker.net>
From: Andrew Solomon <andrew [...] illywhacker.net>
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 }, < }); --- Show quoted text
> #my %args = validate( @_, { > #InstanceId => { type => SCALAR }, > #Attribute => { type => SCALAR }, > #Value => { type => SCALAR }, > #}); > > my %args = (@_);
kind regards Andrew
On Sat Aug 04 20:27:08 2012, andrew@illywhacker.net wrote: Show quoted text
> 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?
Subject: Re: [rt.cpan.org #78779] modify_instance_attribute
Date: Tue, 7 Aug 2012 23:40:03 +0100
To: bug-Net-Amazon-EC2 [...] rt.cpan.org
From: Andrew Solomon <andrew [...] illywhacker.net>
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
Show quoted text
> 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&BlockD eviceMapping.1.Ebs.DeleteOnTermination=true Show quoted text
> > omitting the key 'Value'. > > How does that sound?
Sounds great. Have a look at https://github.com/mrallen1/net-amazon- ec2/commit/98b7c2d2fcd05523b5e6aa7dea1d71a0b4fb3275 and let me know if that works for you - if you could test that in your script I'd be grateful. Thanks. Mark
Subject: Re: [rt.cpan.org #78779] modify_instance_attribute
Date: Fri, 10 Aug 2012 00:13:21 +0100
To: bug-Net-Amazon-EC2 [...] rt.cpan.org
From: Andrew Solomon <andrew [...] illywhacker.net>
On Thu, Aug 9, 2012 at 4:18 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 > >
>> 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&BlockD > eviceMapping.1.Ebs.DeleteOnTermination=true
>> >> omitting the key 'Value'. >> >> How does that sound?
> > Sounds great. Have a look at > > https://github.com/mrallen1/net-amazon- > ec2/commit/98b7c2d2fcd05523b5e6aa7dea1d71a0b4fb3275 > > and let me know if that works for you - if you could test that in your script I'd be grateful. > > Thanks. > > Mark >
Thanks Mark - worked a treat! All the best Andrew
On Thu Aug 09 19:13:32 2012, andrew@illywhacker.net wrote: Show quoted text
> Thanks Mark - worked a treat!
Great! Thanks.
Just released 0.21