AWS-Lambda-Quick
view release on metacpan or search on metacpan
lib/AWS/Lambda/Quick.pm view on Meta::CPAN
package AWS::Lambda::Quick;
use strict;
use warnings;
use autodie;
our $VERSION = '1.0002';
use AWS::Lambda::Quick::Processor ();
sub import {
shift;
# where's the source code of the script calling us?
my ( undef, $file, undef ) = caller;
# process the whole thing
my $proc = AWS::Lambda::Quick::Processor->new(
src_filename => $file,
@_,
);
my $url = $proc->process;
print "$url\n" or die "problem with fh: $!";
# and exit before we run the remainder of the script
# (since that's meant to be run on AWS Lambda, and we're just
# uploading at this time!)
exit;
}
1;
__END__
=head1 NAME
AWS::Lambda::Quick - quickly create a REST accesible AWS Lambda function
=head1 SYNOPSIS
Write a simple script containing a 'handler' function:
#!/usr/bin/perl
use strict;
use warnings;
use AWS::Lambda::Quick (
name => 'hello-world',
);
sub handler {
my $data = shift;
my $name = $data->{queryStringParameters}{who} // "World";
return {
statusCode => 200,
headers => {
'Content-Type' => 'text/plain',
},
body => "Hello, $name",
};
}
1;
To upload to and configure AWS, just run the script locally:
shell$ perl myscriptname.pl
https://52p3rf890b.execute-api.us-east-1.amazonaws.com/quick/hello-world
Then you can access it from anywhere:
shell$ curl https://52p3rf890b.execute-api.us-east-1.amazonaws.com/quick/hello-world?who=Mark'
Hello, Mark
=head1 DESCRIPTION
This module allows you to very quickly create a Perl based AWS
Lambda function which can be accessed via HTTP.
Coding Lambda functions in Perl is straight forward: You need only
implement a script with the one C<handler> function that returns the
( run in 1.583 second using v1.01-cache-2.11-cpan-995e09ba956 )