NAME
AWS::CLIWrapper - Wrapper module for aws-cli
SYNOPSIS
use AWS::CLIWrapper;
my $aws = AWS::CLIWrapper->new(
region => 'us-west-1',
);
my $res = $aws->ec2(
'describe-instances' => {
instance_ids => ['i-XXXXX', 'i-YYYYY'],
},
timeout => 18, # optional. default is 30 seconds
);
if ($res) {
for my $rs ( @{ $res->{Reservations} }) {
for my $is (@{ $rs->{Instances} }) {
print $is->{InstanceId},"\n";
}
}
} else {
warn $AWS::CLIWrapper::Error->{Code};
warn $AWS::CLIWrapper::Error->{Message};
}
DESCRIPTION
AWS::CLIWrapper is wrapper module for aws-cli (recommend: awscli >= 1.0.0, requires: >= 0.40.0).
AWS::CLIWrapper is a just wrapper module, so you can do everything what you can do with aws-cli.
See note below about making sure AWS credentials are accessible (especially under crond)
METHODS
- new($param:HashRef)
-
Constructor of AWS::CLIWrapper. Acceptable param are:
region region_name:Str profile profile_name:Str endpoint_url endpoint_url:Str
- acm($operation:Str, $param:HashRef, %opt:Hash)
- apigateway($operation:Str, $param:HashRef, %opt:Hash)
- autoscaling($operation:Str, $param:HashRef, %opt:Hash)
- cloudformation($operation:Str, $param:HashRef, %opt:Hash)
- cloudfront($operation:Str, $param:HashRef, %opt:Hash)
- cloudhsm($operation:Str, $param:HashRef, %opt:Hash)
- cloudsearch($operation:Str, $param:HashRef, %opt:Hash)
- cloudsearchdomain($operation:Str, $param:HashRef, %opt:Hash)
- cloudtrail($operation:Str, $param:HashRef, %opt:Hash)
- cloudwatch($operation:Str, $param:HashRef, %opt:Hash)
- codecommit($operation:Str, $param:HashRef, %opt:Hash)
- codepipeline($operation:Str, $param:HashRef, %opt:Hash)
- cognito_identity($operation:Str, $param:HashRef, %opt:Hash)
- cognito_sync($operation:Str, $param:HashRef, %opt:Hash)
- configservice($operation:Str, $param:HashRef, %opt:Hash)
- configure($operation:Str, $param:HashRef, %opt:Hash)
- datapipeline($operation:Str, $param:HashRef, %opt:Hash)
- deploy($operation:Str, $param:HashRef, %opt:Hash)
- devicefarm($operation:Str, $param:HashRef, %opt:Hash)
- directconnect($operation:Str, $param:HashRef, %opt:Hash)
- ds($operation:Str, $param:HashRef, %opt:Hash)
- dynamodb($operation:Str, $param:HashRef, %opt:Hash)
- dynamodbstreams($operation:Str, $param:HashRef, %opt:Hash)
- ec2($operation:Str, $param:HashRef, %opt:Hash)
- ecr($operation:Str, $param:HashRef, %opt:Hash)
- ecs($operation:Str, $param:HashRef, %opt:Hash)
- efs($operation:Str, $param:HashRef, %opt:Hash)
- elasticache($operation:Str, $param:HashRef, %opt:Hash)
- elasticbeanstalk($operation:Str, $param:HashRef, %opt:Hash)
- elastictranscoder($operation:Str, $param:HashRef, %opt:Hash)
- elb($operation:Str, $param:HashRef, %opt:Hash)
- emr($operation:Str, $param:HashRef, %opt:Hash)
- es($operation:Str, $param:HashRef, %opt:Hash)
- events($operation:Str, $param:HashRef, %opt:Hash)
- firehose($operation:Str, $param:HashRef, %opt:Hash)
- gamelift($operation:Str, $param:HashRef, %opt:Hash)
- glacier($operation:Str, $param:HashRef, %opt:Hash)
- iam($operation:Str, $param:HashRef, %opt:Hash)
- importexport($operation:Str, $param:HashRef, %opt:Hash)
- inspector($operation:Str, $param:HashRef, %opt:Hash)
- iot($operation:Str, $param:HashRef, %opt:Hash)
- iot_data($operation:Str, $param:HashRef, %opt:Hash)
- kinesis($operation:Str, $param:HashRef, %opt:Hash)
- kms($operation:Str, $param:HashRef, %opt:Hash)
- lambda($operation:Str, $param:HashRef, %opt:Hash)
- logs($operation:Str, $param:HashRef, %opt:Hash)
- machinelearning($operation:Str, $param:HashRef, %opt:Hash)
- marketplacecommerceanalytics($operation:Str, $param:HashRef, %opt:Hash)
- opsworks($operation:Str, $param:HashRef, %opt:Hash)
- rds($operation:Str, $param:HashRef, %opt:Hash)
- redshift($operation:Str, $param:HashRef, %opt:Hash)
- route53($operation:Str, $param:HashRef, %opt:Hash)
- route53domains($operation:Str, $param:HashRef, %opt:Hash)
- s3($operation:Str, $path:ArrayRef, $param:HashRef, %opt:Hash)
- s3api($operation:Str, $param:HashRef, %opt:Hash)
- sdb($operation:Str, $param:HashRef, %opt:Hash)
- ses($operation:Str, $param:HashRef, %opt:Hash)
- sns($operation:Str, $param:HashRef, %opt:Hash)
- sqs($operation:Str, $param:HashRef, %opt:Hash)
- ssm($operation:Str, $param:HashRef, %opt:Hash)
- storagegateway($operation:Str, $param:HashRef, %opt:Hash)
- sts($operation:Str, $param:HashRef, %opt:Hash)
- support($operation:Str, $param:HashRef, %opt:Hash)
- swf($operation:Str, $param:HashRef, %opt:Hash)
- waf($operation:Str, $param:HashRef, %opt:Hash)
- workspaces($operation:Str, $param:HashRef, %opt:Hash)
-
AWS::CLIWrapper provides methods same as services of aws-cli. Please refer to `aws help`.
First arg "operation" is same as operation of aws-cli. Please refer to `aws SERVICE help`.
Second arg "param" is same as command line option of aws-cli. Please refer to `aws SERVICE OPERATION help`.
Key of param is string that trimmed leading "--" and replaced "-" to "_" for command line option (--instance-ids -> instance_ids). Value of param is SCALAR or ARRAYREF or HASHREF.
You can specify
(boolean)
parameter by$AWS::CLIWrapper::true
or$AWS::CLIWrapper::false
.my $res = $aws->ec2('assign-private-ip-addresses', { network_interface_id => $eni_id, private_ip_addresses => [ $private_ip_1, $private_ip_2 ], allow_reassignment => $AWS::CLIWrapper::true, })
Special case: several OPERATIONs take a single arg. For example "aws s3api get-object ... output_file". In this case, You can specify below using
output_file
key:my $res = $aws->s3api('get-object', { bucket => 'my-bucket', key => 'blahblahblah', output_file => '/path/to/output/file', })
Special case: s3 OPERATION takes one or two arguments in addition to options. For example "aws s3 cp LocalPath s3://S3Path". Pass an extra ARRAYREF to the s3 method in this case:
my $res = $aws->s3('cp', ['LocalPath', 's3://S3Path'], { exclude => '*.bak', })
Special case: s3 OPERATION can take --include and --exclude option multiple times. For example "aws s3 sync --exclude 'foo' --exclude 'bar' LocalPath s3://S3Path", Pass ARRAYREF as value of
include
orexclude
in this case:my $res = $aws->s3('sync', ['LocalPath', 's3://S3Path'], { exclude => ['foo', 'bar'], })
Third arg "opt" is optional. Available key/values are below:
timeout => Int Maximum time the "aws" command is allowed to run before aborting. default is 30 seconds. nofork => Int (>0) Call IPC::Cmd::run vs. IPC::Cmd::run_forked (mostly useful if/when in perl debugger). Note: 'timeout', if used with 'nofork', will merely cause an alarm and return. ie. 'run' will NOT kill the awscli command like 'run_forked' will.
ENVIRONMENT
- HOME: used by default by /usr/bin/aws utility to find it's credentials (if none are specified)
-
Special note: cron on Linux will often have a different HOME "/" instead of "/root" - set $ENV{'HOME'} to use the default credentials or specify $ENV{'AWS_CONFIG_FILE'} directly.
- AWS_CONFIG_FILE
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
-
See documents of aws-cli.
AUTHOR
HIROSE Masaaki <hirose31 _at_ gmail.com>
REPOSITORY
https://github.com/hirose31/AWS-CLIWrapper
git clone git://github.com/hirose31/AWS-CLIWrapper.git
patches and collaborators are welcome.
SEE ALSO
http://aws.amazon.com/cli/, https://github.com/aws/aws-cli, http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html, https://github.com/boto/botocore,
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.