AWS-CLIWrapper
view release on metacpan or search on metacpan
- awscli >= 0.14.0 requires --count pramter in ec2
run-instances, but < 0.14.0 requires --min-count and
--max-count. So AWS::CLIWrapper converts these parameters by
version of awscli
- awscli >= 0.15.0 changed "s3" to "s3api" and "s3" became
another command... So AWS::CLIWrapper calls "s3api"
internally instead of "s3" if awscli >= 0.15.0 and
subcommand seems to old "s3"'s one(--list-buckets,
--put-object and so on), and calls "s3" instead of "s3api"
if awscli < 0.15.0.
- I gave up to work around incompatible changes in type of
returned data structure. For example, awscli 1.0.0
"elb describe-load-balancers" returns hash, on the other
hand, awscli 0.9.3 returns list. Please upgrade awscli
carefully.
0.09 2013-09-02
* Update document on nofork and timeout (thanks @mschrader)
* Add some methods for aws-cli/0.16.0
0.08 2013-07-05
},
"test" : {
"requires" : {
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"repository" : {
"type" : "git",
"url" : "https://github.com/hirose31/AWS-CLIWrapper.git",
"web" : "https://github.com/hirose31/AWS-CLIWrapper"
}
},
"version" : "1.27",
"x_serialization_backend" : "JSON::PP version 2.27400_02"
}
Makefile.PL view on Meta::CPAN
},
"TEST_REQUIRES" => {
"Test::More" => 0
},
"VERSION_FROM" => "lib/AWS/CLIWrapper.pm",
"MIN_PERL_VERSION" => 5.008001,
"META_MERGE" => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
web => 'https://github.com/hirose31/AWS-CLIWrapper',
url => 'https://github.com/hirose31/AWS-CLIWrapper.git',
},
},
},
"test" => {
"TESTS" => "t/*.t"
}
);
lib/AWS/CLIWrapper.pm view on Meta::CPAN
}
sub param2opt {
my($k, $v) = @_;
my @v;
$k =~ s/_/-/g;
$k = '--'.$k;
my $type = ref $v;
if (! $type) {
if ($k eq '--output-file') {
# aws s3api get-object takes a single arg for output file path
return $v;
} else {
push @v, $v;
}
} elsif ($type eq 'ARRAY') {
push @v, map { ref($_) ? encode_json(_compat_kv($_)) : $_ } @$v;
} elsif ($type eq 'HASH') {
push @v, encode_json(_compat_kv($v));
} elsif ($type eq 'AWS::CLIWrapper::Boolean') {
if ($$v == 1) {
return ($k);
} else {
return ();
}
} else {
push @v, $v;
}
return ($k, @v);
}
# >= 0.14.0 : Key, Values, Value, Name
# < 0.14.0 : key, values, value, name
sub _compat_kv_uc {
my $v = shift;
my $type = ref $v;
if ($type && $type eq 'HASH') {
for my $hk (keys %$v) {
if ($hk =~ /^(?:key|name|values|value)$/) {
$v->{ucfirst($hk)} = delete $v->{$hk};
}
}
}
return $v;
}
# sub _compat_kv_lc {
# my $v = shift;
# my $type = ref $v;
# if ($type && $type eq 'HASH') {
# for my $hk (keys %$v) {
# if ($hk =~ /^(?:Key|Name|Values|Values)$/) {
# $v->{lc($hk)} = delete $v->{$hk};
# }
# }
# }
# return $v;
# }
# Drop support < 0.14.0 for preventing execute aws command in loading this module
xt/12_nested-boolean.t view on Meta::CPAN
my $AMI_ID = 'ami-0cc905e12087478be'; # Ubuntu 18.04
my $aws = AWS::CLIWrapper->new;
my $res;
my $err;
$res = $aws->ec2('run-instances', {
count => 1,
image_id => $AMI_ID,
instance_type => 't2.micro',
key_name => 'hirose31-aws-tokyo',
network_interfaces => [
{
DeviceIndex => 0,
SubnetId => 'subnet-00c69dad8729ad024',
PrivateIpAddress => "10.0.0.240",
Groups => [ 'sg-0ec4572b2c015784c' ],
AssociatePublicIpAddress => JSON::true, # not $AWS::CLIWrapper::true,
},
],
( run in 3.106 seconds using v1.01-cache-2.11-cpan-64ef6c95b5d )