Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: stanaka/net-amazon-ec2
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: rluser/net-amazon-ec2
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Oct 16, 2011

  1. Copy the full SHA
    054a7a2 View commit details
  2. Copy the full SHA
    51ff2ee View commit details

Commits on Oct 23, 2011

  1. Copy the full SHA
    8156574 View commit details
  2. documentation fix

    rluser committed Oct 23, 2011
    Copy the full SHA
    e4a84a5 View commit details
Showing with 31 additions and 6 deletions.
  1. +1 −0 Makefile.PL
  2. +15 −2 lib/Net/Amazon/EC2.pm
  3. +2 −1 lib/Net/Amazon/EC2/GroupSet.pm
  4. +13 −3 t/02_live.t
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ name 'Net-Amazon-EC2';
all_from 'lib/Net/Amazon/EC2.pm';

# Specific dependencies
recommends 'LWP::Protocol::https' => 0;
requires 'Digest::HMAC_SHA1' => 1.01;
requires 'MIME::Base64' => 0;
requires 'LWP::UserAgent' => 0;
17 changes: 15 additions & 2 deletions lib/Net/Amazon/EC2.pm
Original file line number Diff line number Diff line change
@@ -136,6 +136,12 @@ The region to run the API requests through. The options are:
=back
=item ssl (optional)
If set to a true value, the base_url will use https:// instead of http://. Setting base_url explicitly will override this. Use depends on LWP::Protocol::https; if not installed it will die at runtime trying to fetch the url.
=back
=item debug (optional)
A flag to turn on debugging. It is turned off by default
@@ -150,10 +156,13 @@ has 'debug' => ( is => 'ro', isa => 'Str', required => 0, default => 0 );
has 'signature_version' => ( is => 'ro', isa => 'Int', required => 1, default => 1 );
has 'version' => ( is => 'ro', isa => 'Str', required => 1, default => '2011-01-01' );
has 'region' => ( is => 'ro', isa => 'Str', required => 1, default => 'us-east-1' );
has 'ssl' => ( is => 'ro', isa => 'Bool', required => 1, default => 0 );
has 'timestamp' => (
is => 'ro',
isa => 'Str',
required => 1,
lazy => 1,
clearer => '_clear_timestamp',
default => sub {
my $ts = time2isoz();
chop($ts);
@@ -168,7 +177,7 @@ has 'base_url' => (
required => 1,
lazy => 1,
default => sub {
return 'http://' . $_[0]->region . '.ec2.amazonaws.com';
return 'http' . ($_[0]->ssl ? 's' : '') . '://' . $_[0]->region . '.ec2.amazonaws.com';
}
);

@@ -177,6 +186,7 @@ sub _sign {
my %args = @_;
my $action = delete $args{Action};
my %sign_hash = %args;
$self->_clear_timestamp;
$sign_hash{AWSAccessKeyId} = $self->AWSAccessKeyId;
$sign_hash{Action} = $action;
$sign_hash{Timestamp} = $self->timestamp;
@@ -941,7 +951,8 @@ The availability zone to create the volume in.
=back
Returns true if the releasing succeeded.
Returns a Net::Amazon::EC2::Volume object containing the resulting volume
status
=cut

@@ -1715,6 +1726,7 @@ sub describe_instances {
foreach my $group_arr (@{$reservation_set->{groupSet}{item}}) {
my $group = Net::Amazon::EC2::GroupSet->new(
group_id => $group_arr->{groupId},
group_name => $group_arr->{groupName},
);
push @$group_sets, $group;
}
@@ -3695,6 +3707,7 @@ sub run_instances {
foreach my $group_arr (@{$xml->{groupSet}{item}}) {
my $group = Net::Amazon::EC2::GroupSet->new(
group_id => $group_arr->{groupId},
group_name => $group_arr->{groupName},
);
push @$group_sets, $group;
}
3 changes: 2 additions & 1 deletion lib/Net/Amazon/EC2/GroupSet.pm
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ The ID of the group.
=cut

has 'group_id' => ( is => 'ro', isa => 'Str', required => 1 );
has 'group_name' => ( is => 'ro', isa => 'Str', required => 1 );

__PACKAGE__->meta->make_immutable();

@@ -35,4 +36,4 @@ under the same terms as Perl itself.
=cut

no Moose;
1;
1;
16 changes: 13 additions & 3 deletions t/02_live.t
Original file line number Diff line number Diff line change
@@ -12,11 +12,21 @@ BEGIN {
}
};

my $ec2 = Net::Amazon::EC2->new(
#try ssl first
my $ec2 = eval {
Net::Amazon::EC2->new(
AWSAccessKeyId => $ENV{AWS_ACCESS_KEY_ID},
SecretAccessKey => $ENV{SECRET_ACCESS_KEY},
ssl => 1,
debug => 0,
);
);
};

$ec2 = Net::Amazon::EC2->new(
AWSAccessKeyId => $ENV{AWS_ACCESS_KEY_ID},
SecretAccessKey => $ENV{SECRET_ACCESS_KEY},
debug => 0,
) if $@;

isa_ok($ec2, 'Net::Amazon::EC2');

@@ -82,7 +92,7 @@ my $run_result = $ec2->run_instances(
InstanceType => 'm1.small'
);
isa_ok($run_result, 'Net::Amazon::EC2::ReservationInfo');
ok($run_result->group_set->[0]->group_id eq "test_group", "Checking for running instance");
ok($run_result->group_set->[0]->group_name eq "test_group", "Checking for running instance");
my $instance_id = $run_result->instances_set->[0]->instance_id;

# describe_instances