Mojolicious::Plugin::AWS - AWS via Mojolicious
# Mojolicious $self->plugin('Mojolicious::Plugin::AWS'); # Mojolicious::Lite plugin 'Mojolicious::Plugin::AWS'; $c->sns_publish( region => 'us-east-2', topic => $topic_arn, subject => 'my subject', message => {default => 'my message'}, access_key => $access_key, secret => $secret_key )->then( sub { my $tx = shift; say $tx->res->json('/PublishResponse/PublishResult/MessageId'); } );
Mojolicious::Plugin::AWS is a Mojolicious plugin for accessing Amazon Web Service resources. This module is ALPHA QUALITY meaning its interface is likely to change in backward-incompatible ways. See the "CAVEATS" section below.
This module is alpha quality. This means that its interface will likely change in backward-incompatible ways, that its performance is unreliable, that the example code snippets may be wrong or out of date, and that the code quality is only meant as a proof-of-concept. Its use is discouraged except for experimental, non-production deployments.
Mojolicious::Plugin::AWS implements the following helpers.
$c->sns_publish( region => $aws_region, access_key => $access_key, secret_key => $secret_key, topic => $topic_arn, subject => 'Automatic Message', message => { default => 'default message', https => 'this is sent to your HTTPS endpoint' } )->then( sub { my $tx = shift; say STDERR "Response: " . $tx->res->body; } )->wait;
Returns a Mojo::Promise object that contains the results of the AWS SNS Publish command:
use Data::Dumper; say Dumper $tx->res->json; { 'PublishResponse' => { 'PublishResult' => { 'MessageId' => '5d9ab65c-0363-5a41-dba1-f1bb241d9132', 'SequenceNumber' => undef }, 'ResponseMetadata' => { 'RequestId' => '3b8c6c31-a7eb-b5d6-58d4-df0fc3b80192' } } }
$c->s3_retrieve( region => $aws_region, access_key => $access_key, secret_key => $secret_key, url => Mojo::URL->new($s3_url), )->then( sub { my $tx = shift; Mojo::File->new('my-file.jpg')->spurt($tx->res->body); } )->catch( sub { my $err = shift; warn "Unable to retrieve object: $err"; } )->wait;
Returns a Mojo::Promise object that contains the results of the AWS S3 Retrieve command, usually the object/file you requested.
Mojolicious::Plugin::AWS inherits all methods from Mojolicious::Plugin and implements the following new ones.
$plugin->register(Mojolicious->new);
Register plugin in Mojolicious application.
Scott Wiersdorf, <scott@perlcode.org>
AdvanStaff HR
Copyright (C) 2019, Scott Wiersdorf.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Mojolicious, Mojolicious::Guides, https://mojolicious.org.
To install Mojolicious::Plugin::AWS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::AWS
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::AWS
For more information on module installation, please visit the detailed CPAN module installation guide.