Incorrect search filter: invalid characters - *.p[ml]
AWS-CLIWrapper

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    [IMPROVEMENTS]
        - Optionally catch aws-cli errors and retry (PR #23 by @nohuhu)
        - Add servics with aws-cli/1.27.163

1.26  2023-05-25
    [IMPROVEMENTS]
        - Add `region` method to allow introspection on constructor arguments (PR #22 by @nohuhu)

1.25  2023-03-16
    [BUG FIXES]
        - Fix AWS_CLIWRAPPER_TIMEOUT test (PR #20 by @nohuhu)

1.24  2023-03-15
    [IMPROVEMENTS]
        - Allow overriding aws-cli execution timeout via environment variable (PR #19 by @nohuhu)
        - Add servics with aws-cli/1.27.91

1.23  2022-03-23
    [IMPROVEMENTS]
        - Fix test suite fails with aws-cli v2 (rt 141885)

1.22  2022-03-17
    [IMPROVEMENTS]
        - optionally croak() on errors (PR #18 by @nohuhu)
        - Add servics with aws-cli/1.22.76

1.21  2021-05-20
    [IMPROVEMENTS]
        - Add servics with aws-cli/1.19.76

Changes  view on Meta::CPAN


0.07  2013-06-19
  * Add "output_file" key name of parameter for aws s3 get-object
  * Enable to specify timeout before aborting "aws" command

0.06  2013-06-12
  * Add some methods for aws-cli/0.12.0
  * Fix died when failed to parse result as JSON (aws s3)

0.05  2013-05-01
  * Add some methods for latest awscli (0.9.2)

0.04  2013-04-30
  * Adjust $Error for incompatible changes of aws-cli/botocore

0.03  2013-03-11
  * Add $AWS::CLIWrapper::true and $AWS::CLIWrapper::false for boolean parameter

0.02  2013-01-24
  * Support parameter: structure in list

META.json  view on Meta::CPAN

      },
      "runtime" : {
         "requires" : {
            "IPC::Cmd" : "0",
            "JSON" : "2",
            "String::ShellQuote" : "0",
            "perl" : "5.008001",
            "version" : "0.77"
         }
      },
      "test" : {
         "requires" : {
            "Test::More" : "0"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "repository" : {
         "type" : "git",
         "url" : "https://github.com/hirose31/AWS-CLIWrapper.git",

Makefile.PL  view on Meta::CPAN

    "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"
    }
);


unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
    my $tr = delete $WriteMakefileArgs{TEST_REQUIRES};
    my $br = $WriteMakefileArgs{BUILD_REQUIRES};
    for my $mod ( keys %$tr ) {
        if ( exists $br->{$mod} ) {

cpanfile  view on Meta::CPAN

requires 'JSON', '2';
requires 'String::ShellQuote';
requires 'perl', '5.005';
requires 'version';
requires 'perl', '5.008001';

on configure => sub {
    requires 'ExtUtils::MakeMaker', '6.30';
};

on test => sub {
    requires 'Test::More';
    requires 'File::Temp';
};

on develop => sub {
    requires 'Test::Dependencies';
    requires 'Test::Perl::Critic';
    requires 'Test::LocalFunctions';
    requires 'Test::UsedModules';
    requires 'File::Temp';

lib/AWS/CLIWrapper.pm  view on Meta::CPAN

L<https://github.com/hirose31/AWS-CLIWrapper>

  git clone git://github.com/hirose31/AWS-CLIWrapper.git

patches and collaborators are welcome.

=head1 SEE ALSO

L<http://aws.amazon.com/cli/>,
L<https://github.com/aws/aws-cli>,
L<http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html>,
L<https://github.com/boto/botocore>,

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

# for Emacsen

t/00_compile.t  view on Meta::CPAN

use strict;
use Test::More;

BEGIN { use_ok 'AWS::CLIWrapper' }

done_testing;

t/01_new.t  view on Meta::CPAN

use strict;
use Test::More;

require AWS::CLIWrapper;
note("new");
my $obj = new_ok("AWS::CLIWrapper");

# diag explain $obj

done_testing;

t/03_awscli_path.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;

use AWS::CLIWrapper;

subtest 'default' => sub {
  my $cli = AWS::CLIWrapper->new;
  is $cli->awscli_path, 'aws';
};

subtest 'specify explicit awscli path' => sub {
  my $cli = AWS::CLIWrapper->new(awscli_path => '/usr/local/bin/aws');
  is $cli->awscli_path, '/usr/local/bin/aws';
};

done_testing;

t/03_awscli_timeout.t  view on Meta::CPAN

}

{
  local $ENV{AWS_CLIWRAPPER_TIMEOUT} = 3600;

  my $aws = AWS::CLIWrapper->new();

  is $aws->{timeout}, 3600, "timeout set via env variable";
}

done_testing;

t/03_awscli_version.t  view on Meta::CPAN

use Test::More;

use AWS::CLIWrapper;

my $cli_wrapper = AWS::CLIWrapper->new;
ok($cli_wrapper->awscli_version >= 0, $cli_wrapper->awscli_version);
if ($cli_wrapper->awscli_version > 0) {
    ok($cli_wrapper->awscli_version > 0.001);
}

done_testing;

t/03_region.t  view on Meta::CPAN

use Test::More;

use AWS::CLIWrapper;

my $cli = AWS::CLIWrapper->new(
  region => 'us-west-1',
);

is $cli->region, 'us-west-1', "region ok";

done_testing;

t/04_errors.t  view on Meta::CPAN

use strict;
use Test::More;

use AWS::CLIWrapper;

# Default error handling
my $aws = AWS::CLIWrapper->new;
if ($aws->awscli_version == 0) {
    plan skip_all => 'not found aws command';
} else {
    plan tests => 4;
}

my $res = $aws->elbv2();

is $res, undef, "default result is undefined";

# Is this a TODO?
is $AWS::CLIWrapper::Error->{Code}, "Unknown", "default error code match";

my $want_err_msg = qr!exited with code \[\d+\]

t/05_catch_error_options.t  view on Meta::CPAN

no warnings 'uninitialized';

use Test::More;
use AWS::CLIWrapper;

my %default_args = (
  awscli_path => 't/bin/mock-aws',
  nofork => 1,
);

my $tests = eval join "\n", <DATA> or die "$@";

for my $test_name (keys %$tests) {
  next if @ARGV and not grep { $_ eq $test_name } @ARGV;

  my $test = $tests->{$test_name};
  my ($args, $env, $method, $want) = @$test{qw(args env method want)};

  $env = {} unless $env;

  local @ENV{keys %$env} = values %$env;

  my $aws = AWS::CLIWrapper->new(%default_args, %{$args || {}});
  my $have = $aws->$method;

  if ('ARRAY' eq ref $want) {
    cmp_ok $have, $_->[0], $_->[1], "$test_name " . (join ' ', @$_) for @$want;
  }
  else {
    is $have, $want, $test_name;
  }
}


done_testing;

__DATA__
# line 41
{
  'mock-aws version' => {
    method => 'awscli_version',
    want => '2.42.4242',
  },
  'default-catch_error_pattern' => {
    method => 'catch_error_pattern',

t/06_catch_errors.t  view on Meta::CPAN

use Test::More;
use File::Temp 'tempfile';

use AWS::CLIWrapper;

my %default_wrapper_args = (
  awscli_path => 't/bin/mock-aws',
  nofork => 1,
);

my $tests = eval join "\n", <DATA> or die "$@";

for my $test_name (keys %$tests) {
  next if @ARGV and not grep { $_ eq $test_name } @ARGV;

  my $test = $tests->{$test_name};
  my ($wrapper_args, $env, $command, $subcommand, $cmd_args)
    = @$test{qw(wrapper_args env command subcommand cmd_args)};
  
  $env = {} unless $env;

  my ($tmp_fh, $tmp_name) = tempfile;
  print $tmp_fh $test->{retries} || 1;
  close $tmp_fh;

  local $ENV{AWS_CLIWRAPPER_TEST_ERROR_COUNTER_FILE} = $tmp_name;
  local $ENV{AWS_CLIWRAPPER_TEST_DIE_WITH_ERROR} = $test->{error_to_die_with}
    if $test->{error_to_die_with};
  
  local @ENV{keys %$env} = values %$env;
  
  $AWS::CLIWrapper::Error = { Message => '', Code => '' };

  my $aws = AWS::CLIWrapper->new(%default_wrapper_args, %{$wrapper_args || {}});
  my $res = eval { $aws->$command($subcommand, @{$cmd_args || []}) };

  if ($test->{retries} > 0) {
    open my $fh, "<", $tmp_name;
    my $counter = <$fh>;
    close $fh;

    is $counter, 0, "$test_name retry counter exhausted";
  }

  like "$@", $test->{exception}, "$test_name exception";
  like $AWS::CLIWrapper::Error->{Message}, $test->{error_msg_re},
    "$test_name error message";

  is_deeply $res, $test->{want}, "$test_name result";
}

done_testing;

__DATA__
# line 60
{
  'no-error' => {
    command => 'ecs',
    subcommand => 'list-clusters',
    error_to_die_with => undef,
    error_msg_re => qr{^$},
    exception => qr{^$},

xt/03_pod.t  view on Meta::CPAN

use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();

xt/05_dependencies.t  view on Meta::CPAN

# -*- mode: cperl; -*-

use Test::Dependencies
     exclude => [qw(Test::Dependencies Test::Base Test::Perl::Critic
                        AWS::CLIWrapper)],
     style   => 'light';
if ($ENV{RELEASE_TESTING}) {
    ok_dependencies();
} else {
    my $tb = Test::Dependencies->builder;
    $tb->skip_all('Authors tests');
}

xt/10_ec2.t  view on Meta::CPAN

use Test::More;

use AWS::CLIWrapper;

my $aws = AWS::CLIWrapper->new;
my $res;

$res = $aws->ec2('describe-instances');
ok($res, 'describe-instances all');

my $test_instance_count = 3;
my @instance_ids;
INSTANCE: for my $rs ( @{ $res->{Reservations} }) {
    for my $is (@{ $rs->{Instances} }) {
        push @instance_ids, $is->{InstanceId};
        last INSTANCE if scalar(@instance_ids) >= $test_instance_count;
    }
}

$res = $aws->ec2('describe-instances', { instance_ids => \@instance_ids });
my $got_instance_count = 0;
for my $rs ( @{ $res->{Reservations} }) {
    for my $is (@{ $rs->{Instances} }) {
        $got_instance_count++ if $is->{InstanceId};
    }
}
is($got_instance_count, $test_instance_count, 'describe-instances by instance_ids');

done_testing;

xt/11_struct-in-list.t  view on Meta::CPAN

use AWS::CLIWrapper;

my $aws = AWS::CLIWrapper->new;
my $res;

$res = $aws->ec2('describe-instances', {
    'filters' => [{ Name => 'tag:purpose', Values => ["AC-TEST-*"] }],
   });
ok($res, 'structure in list');

done_testing;

xt/12_nested-boolean.t  view on Meta::CPAN


$res = $aws->ec2('terminate-instances', {
    instance_ids => [$instance_id],
})
    or die sprintf("Code : %s\nMessage: %s",
                    $AWS::CLIWrapper::Error->{Code},
                    $AWS::CLIWrapper::Error->{Message},
                );
ok($res, 'terminate-instances');

done_testing;

xt/19_error.t  view on Meta::CPAN

### required option
$res = $aws->ec2('run-instances');
$err = $AWS::CLIWrapper::Error;
ok(!$res, 'required option');

  is($err->{Code},    'Unknown',       'err Code');
like($err->{Message}, qr/(?:is required|MissingParameter)/, 'err Message');


###
done_testing;

xt/20_s3-sync.t  view on Meta::CPAN


use File::Temp qw(tempdir);
use File::Glob qw(:glob); # for globbing pattern contains whitespace
use AWS::CLIWrapper;

my $aws = AWS::CLIWrapper->new;
my $cleanup = 0;

{
    my $tmpdir = tempdir( CLEANUP => $cleanup );
    test_sync("normal",
              's3://aws-cliwrapper-test' => $tmpdir);
}

{
    my $tmpdir = tempdir( CLEANUP => $cleanup );
    test_sync("source file contains space",
              's3://aws-cliwrapper-test/file-space' => $tmpdir);
}
{
    my $tmpdir = tempdir("s3-sync-sfs XXXXXX",
                         CLEANUP => $cleanup,
                         TMPDIR  => 1,
                     );
    test_sync("source file contains space and dest dir contains space",
              's3://aws-cliwrapper-test/file-space' => $tmpdir);
}

{
    my $tmpdir = tempdir( CLEANUP => $cleanup );
    test_sync("source dir contains space",
              's3://aws-cliwrapper-test/dir space' => $tmpdir);
}
{
    my $tmpdir = tempdir("s3-sync-sds XXXXXX",
                         CLEANUP => $cleanup,
                         TMPDIR  => 1,
                     );
    test_sync("source dir contains space and dest dir contains space",
              's3://aws-cliwrapper-test/dir space' => $tmpdir);
}

{
    my $tmpdir = tempdir("XXXXXXXX",
                         CLEANUP => $cleanup,
                         TMPDIR  => 1,
                     );
    test_sync("source dir contains single quote",
              "s3://aws-cliwrapper-test/dir'single" => $tmpdir);
}
{
    my $tmpdir = tempdir("s3-sync-dfq'XXXXXX",
                          CLEANUP => $cleanup,
                          TMPDIR  => 1,
                      );
    test_sync("both source and dest dirs contains single quote",
              "s3://aws-cliwrapper-test/dir'single" => $tmpdir);
}

{
    my $tmpdir = tempdir('XXXXXXXX',
                          CLEANUP => $cleanup,
                          TMPDIR  => 1,
                      );
    test_sync("source dir contains double quote",
              's3://aws-cliwrapper-test/dir"double' => $tmpdir);
}
{
    my $tmpdir = tempdir('s3-sync-dfdq"XXXXXX',
                          CLEANUP => $cleanup,
                          TMPDIR  => 1,
                      );
    test_sync("both source and dest dirs contains double quote",
              's3://aws-cliwrapper-test/dir"double' => $tmpdir);
}

done_testing;

sub test_sync {
    my($desc, $src, $dst) = @_;

    my $res = $aws->s3('sync', [$src => $dst],
                       {
                           'delete' => $AWS::CLIWrapper::true,
                       });
    ok($res, "$desc: $src => $dst");

    my @downloaded = bsd_glob("$dst/*");
    my $nd = scalar @downloaded;

xt/30_compat.t  view on Meta::CPAN

use strict;
use Test::More;

use AWS::CLIWrapper;

my $aws = AWS::CLIWrapper->new;
my $res;

# >= 0.14.0 : Key, Values, Name
# <  0.14.0 : key, values, name
subtest 'Uppercase key, values, name' => sub {
    $res = $aws->ec2('describe-instances', {
        filters => [
            { name => 'tag:purpose', values => ["AC-TEST-2*"] },
            { name => 'instance-state-name', values => ['running'] },
        ],
    });
    ok($res, 'name/values');
    is(scalar(@{$res->{Reservations}[0]{Instances}}), 1, 'name/values count');

    $res = $aws->ec2('describe-instances', {

xt/30_compat.t  view on Meta::CPAN

            { Name => 'tag:purpose', Values => ["AC-TEST-2*"] },
            { Name => 'instance-state-name', Values => ['running'] },
        ],
    });
    ok($res, 'Name/Values');
    is(scalar(@{$res->{Reservations}[0]{Instances}}), 1, 'Name/Values count');
};

# >= 0.14.0 : --count N or --count MIN:MAX
# <  0.14.0 : --min-count N and --max-count N
subtest 'ec2 run-instances: --min-count, --max-count VS --count' => sub {
    # >= 0.14.0 : fail case
    $res = $aws->ec2('run-instances', {
        image_id  => '1',
        min_count => 1,
        max_count => 1,
    });

    ok(!$res); # should fail
    unlike($AWS::CLIWrapper::Error->{Message}, qr/Unknown options:/);

xt/30_compat.t  view on Meta::CPAN

        image_id => '1',
        count    => 1,
    });

    ok(!$res); # should fail
    unlike($AWS::CLIWrapper::Error->{Message}, qr/--(?:min|max)-count is required/);
};

# >= 0.15.0 : s3 and s3api (formerly s3)
# <  0.15.0 : s3 only
subtest 's3 and s3api' => sub {
    plan skip_all => "Suport S3 >= 0.8.0"
        if $aws->awscli_version < 0.8.0;
    # >= 0.15.0
    $res = $aws->s3api('list-buckets');
    ok($res, 's3api list-buckets');

    $res = $aws->s3('list-buckets');
    ok($res, 's3 list-buckets');

    $res = $aws->s3('ls');
    if ($aws->awscli_version >= 0.15.0) {
        ok($res, 's3 ls >= 0.15.0');
    } else {
        like($AWS::CLIWrapper::Error->{Message}, qr/invalid choice: 'ls'/, 's3 ls < 0.15.0');
    }
};

done_testing;

xt/90_dependencies.t  view on Meta::CPAN

# -*- mode: cperl; -*-
use Test::More;
eval "use App::scan_prereqs_cpanfile";

plan skip_all => "App::scan_prereqs_cpanfile required for testing module dependencies"
    if $@;

my $diff = `scan-prereqs-cpanfile --ignore junk --diff cpanfile`;
is($diff, "", "diff cpanfile");

done_testing;

xt/91_usedmodules.t  view on Meta::CPAN

use Test::More;
use Test::UsedModules;
all_used_modules_ok();
done_testing;

xt/92_usedfunctions.t  view on Meta::CPAN

use Test::LocalFunctions;
use Test::More;
all_local_functions_ok({ignore_functions => [qr(_execute|_run|_handle)]});
done_testing;



( run in 0.628 second using v1.01-cache-2.11-cpan-87723dcf8b7 )