I have pasted a very simple test case at the end of this message. Of
course, the point is, this test needs to be run on an instance that has
been launched with an IAM role (as explained here:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html),
so Net::Amazon::EC2 can obtain the credentials automatically.
Also, I think the region needs to be the same region where the instance
is running. I think these role based instance credentials are limited to
the region they are in. But, I may be wrong on that.
When I run the below test on my instance launched with an IAM role
allowing all describe type access in us-east-1a, it fails with
authentication failure. However, if I just change the 'signature_version
= 2', it passes.
-- Selcuk
On 10/2/15 2:59 PM, Mark Allen via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=107491 >
>
> On Fri Oct 02 14:56:50 2015, sozturk@ascllc.net wrote:
>> If you can explain what you mean by a test case, I might be able to do
>> it.
> I mean a .t file which has a failing test case for the authentication you discussed - take a look at
>
https://github.com/mrallen1/net-amazon-ec2/blob/master/t/04_live_v4.t
>
> for inspiration of what this might look like - the test file would be a a series of operation
> that are repeatable so that when I work on this bug I can test a solution until the test
> case(s) pass the test.
>
> Thanks for any help you can provide.
>
> Mark
------- cut
use strict;
use blib;
use Test::More;
BEGIN {
plan tests => 3;
use_ok( 'Net::Amazon::EC2' );
};
my $ec2 = eval {
Net::Amazon::EC2->new(
region => 'us-east-1',
ssl => 1,
#debug => 1,
signature_version => 4,
return_errors => 1,
);
};
isa_ok($ec2, 'Net::Amazon::EC2');
my $regions = $ec2->describe_regions();
my $seen_region = 0;
if (ref($regions) eq 'Net::Amazon::EC2::Errors') {
foreach my $err (@{$regions->errors}) {
print $err->message . "\n";
}
fail("Describing regions");
} else {
foreach my $region (@{$regions}) {
if ($region->region_name eq 'us-east-1') {
$seen_region = 1;
}
}
ok($seen_region == 1, "Describing regions");
}
------ cut