view release on metacpan or search on metacpan
- Europe (Stockholm) eu-north-1 is available
0.0.30 2021-10-06T00:13:52Z
- add amd64 compatible layers
- pre-install some modules
0.0.29 2021-07-16T11:25:47Z
- bump Paws 0.44
0.0.28 2021-06-13T15:46:13Z
- Fix mojibake when the input and the output are utf8 encoded
- Update WwwCounter v4.0.0 in the examples
0.0.27 2021-05-21T03:58:38Z
- Perl 5.34.0 is released
0.0.26 2021-05-09T02:54:24Z
- bump Paws 0.43
0.0.25 2021-03-02T05:32:05Z
- new region Asia Pacific (Osaka) ap-northeast-3 is available
- [Mozilla::CA](https://metacpan.org/pod/Mozilla%3A%3ACA)
- [local::lib](https://metacpan.org/pod/local%3A%3Alib)
[Paws](https://metacpan.org/pod/Paws) is optional. See the "Paws SUPPORT" section.
## AWS X-Ray SUPPORT
[AWS X-Ray](https://aws.amazon.com/xray/) is a service that collects data about requests that your application serves.
You can trace AWS Lambda requests and sends segment data with pre-install module [AWS::XRay](https://metacpan.org/pod/AWS%3A%3AXRay).
use utf8;
use warnings;
use strict;
use AWS::XRay qw/ capture /;
sub handle {
my ($payload, $context) = @_;
capture "myApp" => sub {
capture "nested" => sub {
# do something ...
};
author/perl-stripper/perl-stripper/handler.pl view on Meta::CPAN
use v5.36;
use utf8;
use lib "$ENV{'LAMBDA_TASK_ROOT'}/local/lib/perl5";
use lib "$ENV{'LAMBDA_TASK_ROOT'}/local/lib/perl5/aarch64-linux";
use Perl::Strip;
use Plack::Request;
use AWS::Lambda::PSGI;
mkdir '/tmp/.perl-strip';
my $stripper = Perl::Strip->new(
cache => '/tmp/.perl-strip',
author/update-aws-lambda-al.pl view on Meta::CPAN
}
sub print_paws_arn {
my ($version, $region) = @_;
print $LAYERS->{$version}{$region}{paws_arn};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::AL - AWS Lambda Custom Runtimes based on Amazon Linux
=head1 NO LONGER MAINTAINED
These layers are only for backward compatibility.
We recommend to migrate to Amazon Linux 2023.
These layers are NO LONGER MAINTAINED and WILL NOT RECEIVE ANY UPDATES.
author/update-aws-lambda-al2.pl view on Meta::CPAN
sub print_paws_arn {
my ($version, $region, $arch) = @_;
$arch //= 'x86_64';
print $LAYERS->{$version}{$arch}{$region}{paws_arn};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::AL2 - AWS Lambda Custom Runtimes based on Amazon Linux 2
=head1 NO LONGER MAINTAINED
These layers are only for backward compatibility.
We recommend to migrate to Amazon Linux 2023.
These layers are NO LONGER MAINTAINED and WILL NOT RECEIVE ANY UPDATES.
author/update-aws-lambda-al2023.pl view on Meta::CPAN
sub print_paws_arn {
my ($version, $region, $arch) = @_;
$arch //= 'x86_64';
print $LAYERS->{$version}{$arch}{$region}{paws_arn};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::AL2023 - AWS Lambda Custom Runtimes based on Amazon Linux 2023
=head1 SYNOPSIS
You can get the layer ARN in your script by using C<get_layer_info>.
use AWS::Lambda::AL2023;
examples/cgi/WwwCounter/app.psgi view on Meta::CPAN
use utf8;
use strict;
use warnings;
use Plack::Builder;
use Plack::App::File;
use Plack::App::WrapCGI;
my $count_dir = $ENV{WWWCOUNT_DIR} // ".";
for my $ext("cnt", "acc", "dat") {
open my $fh, ">>", "$count_dir/wwwcount.$ext" or die "cannot touch wwwcount.$ext";
close $fh;
}
mkdir "$count_dir/lock", 0777;
return builder {
mount '/wwwcount.cgi' => Plack::App::WrapCGI->new(
script => "./wwwcount.cgi",
execute => 1,
)->to_app;
mount '/' => Plack::App::File->new(
file => "./sample.html",
encoding => "utf-8",
)->to_app;
};
examples/cgi/WwwCounter/handler.pl view on Meta::CPAN
use utf8;
use warnings;
use strict;
use lib "$ENV{'LAMBDA_TASK_ROOT'}/local/lib/perl5";
use AWS::Lambda::PSGI;
$ENV{WWWCOUNT_DIR} ||= "/tmp";
chdir($ENV{'LAMBDA_TASK_ROOT'});
my $app = require "$ENV{'LAMBDA_TASK_ROOT'}/app.psgi";
my $func = AWS::Lambda::PSGI->wrap($app);
examples/cgi/WwwCounter/sample.html view on Meta::CPAN
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WwwCounterãµã³ãã« - ã¨ã»ã»ã®WWWå
¥é</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
.i { margin-left: 1rem; }
</style>
</head>
<body>
<h2 align="center">WwwCounterãµã³ãã«</h2>
<hr>
examples/cgi/WwwCounter/wwwcount.cgi view on Meta::CPAN
#
# CGIã使ç¨ã§ããããã¹ããè¡ãã
#
sub test {
print "Content-type: text/html\n";
print "\n";
print "<!doctype html>\n";
print "<html>\n";
print "<head>\n";
print "<meta charset='utf-8'>\n";
print "<title>Test</title>\n";
print "</head>\n";
print "<body>\n";
print "<p>OK. CGIã¹ã¯ãªããã¯æ£å¸¸ã«åãã¦ãã¾ãã</p>\n";
if ($g_mailto ne "") {
if (! -f $g_sendmail) {
print "<p>ERROR: $g_sendmail ãåå¨ãã¾ããã</p>\n";
}
}
if (!-d $g_lock_dir) {
examples/custom-docker/handler.pl view on Meta::CPAN
use utf8;
use warnings;
use strict;
sub handle {
my $payload = shift;
return +{"hello" => "lambda"};
}
1;
examples/docker/handler.pl view on Meta::CPAN
use utf8;
use warnings;
use strict;
sub handle {
my $payload = shift;
return +{"hello" => "lambda"};
}
1;
examples/hello/handler.pl view on Meta::CPAN
use utf8;
use warnings;
use strict;
sub handle {
my $payload = shift;
return +{"hello" => "lambda"};
}
1;
examples/psgi/app.psgi view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Plack::Request;
use Plack::Builder;
use Data::Dumper;
return builder {
mount '/foo' => sub {
my $env = shift;
my $req = Plack::Request->new($env);
my $meth = $req->method;
examples/psgi/handler.pl view on Meta::CPAN
use utf8;
use warnings;
use strict;
use AWS::Lambda::PSGI;
my $app = require "$ENV{'LAMBDA_TASK_ROOT'}/app.psgi";
my $func = AWS::Lambda::PSGI->wrap($app);
sub handle {
my $payload = shift;
return $func->($payload);
examples/s3-get-object/handler.pl view on Meta::CPAN
use utf8;
use warnings;
use strict;
use 5.30.0;
use lib "$ENV{'LAMBDA_TASK_ROOT'}/extlocal/lib/perl5";
use Paws;
use Try::Tiny;
use URI::Escape;
my $obj = Paws->service('S3', region => 'ap-northeast-1');
lib/AWS/Lambda.pm view on Meta::CPAN
sub print_paws_arn_al2023 {
my ($version, $region, $arch) = @_;
$arch //= 'x86_64';
print $LAYERS_AL2023->{$version}{$arch}{$region}{paws_arn};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda - Perl support for AWS Lambda Custom Runtime.
=head1 SYNOPSIS
Save the following Perl script as C<handler.pl>.
sub handle {
lib/AWS/Lambda.pm view on Meta::CPAN
=back
L<Paws> is optional. See the "Paws SUPPORT" section.
=head2 AWS X-Ray SUPPORT
L<AWS X-Ray|https://aws.amazon.com/xray/> is a service that collects data about requests that your application serves.
You can trace AWS Lambda requests and sends segment data with pre-install module L<AWS::XRay>.
use utf8;
use warnings;
use strict;
use AWS::XRay qw/ capture /;
sub handle {
my ($payload, $context) = @_;
capture "myApp" => sub {
capture "nested" => sub {
# do something ...
};
lib/AWS/Lambda/AL.pm view on Meta::CPAN
}
sub print_paws_arn {
my ($version, $region) = @_;
print $LAYERS->{$version}{$region}{paws_arn};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::AL - AWS Lambda Custom Runtimes based on Amazon Linux
=head1 NO LONGER MAINTAINED
These layers are only for backward compatibility.
We recommend to migrate to Amazon Linux 2023.
These layers are NO LONGER MAINTAINED and WILL NOT RECEIVE ANY UPDATES.
lib/AWS/Lambda/AL2.pm view on Meta::CPAN
sub print_paws_arn {
my ($version, $region, $arch) = @_;
$arch //= 'x86_64';
print $LAYERS->{$version}{$arch}{$region}{paws_arn};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::AL2 - AWS Lambda Custom Runtimes based on Amazon Linux 2
=head1 NO LONGER MAINTAINED
These layers are only for backward compatibility.
We recommend to migrate to Amazon Linux 2023.
These layers are NO LONGER MAINTAINED and WILL NOT RECEIVE ANY UPDATES.
lib/AWS/Lambda/AL2023.pm view on Meta::CPAN
sub print_paws_arn {
my ($version, $region, $arch) = @_;
$arch //= 'x86_64';
print $LAYERS->{$version}{$arch}{$region}{paws_arn};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::AL2023 - AWS Lambda Custom Runtimes based on Amazon Linux 2023
=head1 SYNOPSIS
You can get the layer ARN in your script by using C<get_layer_info>.
use AWS::Lambda::AL2023;
lib/AWS/Lambda/Bootstrap.pm view on Meta::CPAN
package AWS::Lambda::Bootstrap;
use 5.026000;
use utf8;
use strict;
use warnings;
use HTTP::Tiny;
use JSON::XS qw/decode_json encode_json/;
use Try::Tiny;
use AWS::Lambda;
use AWS::Lambda::Context;
use AWS::Lambda::ResponseWriter;
use Scalar::Util qw(blessed);
use Exporter 'import';
lib/AWS/Lambda/Bootstrap.pm view on Meta::CPAN
}),
});
if (!$resp->{success}) {
die "failed to send error of execution: $resp->{status} $resp->{reason}";
}
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::Bootstrap - the bootstrap script for AWS Lambda Custom Runtime.
=head1 SYNOPSIS
Save the following script as C<bootstrap>, and then zip it with your perl script.
Now, you can start using Perl in AWS Lambda!
#!perl
use strict;
use warnings;
use utf8;
use AWS::Lambda::Bootstrap;
bootstrap(@ARGV);
Pre-built Perl Runtime Layer includes the C<bootstrap> script.
So, if you use the Layer, no need to include the C<bootstrap> script into your zip.
See L<AWS::Lambda> for more details.
=head1 DESCRIPTION
lib/AWS/Lambda/Context.pm view on Meta::CPAN
sub client_context {
return undef; # TODO
}
sub tenant_id {
my $self = shift;
return $self->{tenant_id};
}
1;
=encoding utf-8
=head1 NAME
AWS::Lambda::Context - It's Perl port of the AWS Lambda Context.
=head1 SYNOPSIS
sub handle {
my ($payload, $context) = @_;
# $context is an instance of AWS::Lambda::Context
lib/AWS/Lambda/PSGI.pm view on Meta::CPAN
package AWS::Lambda::PSGI;
use 5.026000;
use utf8;
use strict;
use warnings;
use URI::Escape;
use Plack::Util;
use bytes ();
use MIME::Base64;
use JSON::Types;
use Encode;
use Try::Tiny;
use Plack::Middleware::ReverseProxy;
lib/AWS/Lambda/PSGI.pm view on Meta::CPAN
$env->{'psgi.nonblocking'} = Plack::Util::FALSE;
$env->{'psgix.harakiri'} = Plack::Util::TRUE;
$env->{'psgix.input.buffered'} = Plack::Util::TRUE;
# inject the request id that compatible with Plack::Middleware::RequestId
if ($ctx) {
$env->{'psgix.request_id'} = $ctx->aws_request_id;
$env->{'HTTP_X_REQUEST_ID'} = $ctx->aws_request_id;
}
my $body = encode_utf8($payload->{body} // '');
if ($payload->{isBase64Encoded}) {
$body = decode_base64 $body;
}
open my $input, "<", \$body;
$env->{REQUEST_METHOD} = $payload->{httpMethod};
$env->{'psgi.input'} = $input;
$env->{CONTENT_LENGTH} //= bytes::length($body);
$env->{REQUEST_URI} = $payload->{path};
if ($env->{QUERY_STRING}) {
$env->{REQUEST_URI} .= '?' . $env->{QUERY_STRING};
lib/AWS/Lambda/PSGI.pm view on Meta::CPAN
$env->{'psgi.nonblocking'} = Plack::Util::FALSE;
$env->{'psgix.harakiri'} = Plack::Util::TRUE;
$env->{'psgix.input.buffered'} = Plack::Util::TRUE;
# inject the request id that compatible with Plack::Middleware::RequestId
if ($ctx) {
$env->{'psgix.request_id'} = $ctx->aws_request_id;
$env->{'HTTP_X_REQUEST_ID'} = $ctx->aws_request_id;
}
my $body = encode_utf8($payload->{body} // '');
if ($payload->{isBase64Encoded}) {
$body = decode_base64 $body;
}
open my $input, "<", \$body;
$env->{'psgi.input'} = $input;
$env->{CONTENT_LENGTH} //= bytes::length($body);
my $requestContext = $payload->{requestContext};
$env->{REQUEST_METHOD} = $requestContext->{http}{method};
$env->{REQUEST_URI} = $payload->{rawPath};
if ($env->{QUERY_STRING}) {
lib/AWS/Lambda/PSGI.pm view on Meta::CPAN
}
$body->close;
}
my $type = $singleValueHeaders->{'content-type'} // 'application/octet-stream';
my $isBase64Encoded = $type !~ m(^text/.*|application/(:?json|javascript|xml))i;
if ($isBase64Encoded) {
$content = encode_base64 $content, '';
} else {
$content = try {
# is valid utf-8 string? try to decode as utf-8.
decode_utf8($content, Encode::FB_CROAK | Encode::LEAVE_SRC);
} catch {
# it looks not utf-8 encoding. fallback to base64 encoding.
$isBase64Encoded = 1;
encode_base64 $content, '';
};
}
return +{
isBase64Encoded => bool $isBase64Encoded,
headers => $singleValueHeaders,
multiValueHeaders => $multiValueHeaders,
statusCode => number $status,
lib/AWS/Lambda/PSGI.pm view on Meta::CPAN
return +{
statusCode => number $status,
headers => $headers_hash,
cookies => $cookies,
};
}
1;
__END__
=encoding utf-8
=head1 NAME
AWS::Lambda::PSGI - It translates event of Lambda Proxy Integrations in API Gateway and
Application Load Balancer into L<PSGI>.
=head1 SYNOPSIS
Add the following script into your Lambda code archive.
use utf8;
use warnings;
use strict;
use AWS::Lambda::PSGI;
my $app = require "$ENV{'LAMBDA_TASK_ROOT'}/app.psgi";
my $func = AWS::Lambda::PSGI->wrap($app);
sub handle {
return $func->(@_);
}
lib/AWS/Lambda/ResponseWriter.pm view on Meta::CPAN
package AWS::Lambda::ResponseWriter;
use 5.026000;
use utf8;
use strict;
use warnings;
use Carp qw(croak);
use Scalar::Util qw(blessed);
use MIME::Base64 qw(encode_base64);
use HTTP::Tiny;
my %DefaultPort = (
http => 80,
https => 443,
script/bootstrap view on Meta::CPAN
#!perl
use strict;
use warnings;
use utf8;
use AWS::Lambda::Bootstrap ('bootstrap');
bootstrap(@ARGV);
t/01_echo.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Test::More;
use Test::Deep;
use FindBin;
use lib "$FindBin::Bin/lib";
use BootstrapMock;
use AWS::Lambda::Context;
my $payload = +{
t/02_error.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Test::More;
use FindBin;
use lib "$FindBin::Bin/lib";
use BootstrapMock;
my $error;
my $bootstrap = BootstrapMock->new(
handler => "error.handle",
runtime_api => "example.com",
t/03_init_error.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Test::More;
use FindBin;
use lib "$FindBin::Bin/lib";
use BootstrapMock;
use AWS::Lambda::Context;
use Try::Tiny;
my $error;
my $bootstrap = BootstrapMock->new(
t/04_handler_not_found.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Test::More;
use FindBin;
use lib "$FindBin::Bin/lib";
use BootstrapMock;
use AWS::Lambda::Context;
use Try::Tiny;
my $error;
my $bootstrap = BootstrapMock->new(
t/10_lambda_next.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Test::More;
use Test::TCP;
use HTTP::Server::PSGI;
use FindBin;
use AWS::Lambda::Bootstrap;
use Test::Deep;
my $app_server = Test::TCP->new(
listen => 1,