AWS-Lambda
view release on metacpan or search on metacpan
lib/AWS/Lambda.pm view on Meta::CPAN
return sub {
my $responder = shift;
my $writer = $responder->('application/json');
$writer->write('{"foo": "bar"}');
$writer->close;
};
}
=head1 DESCRIPTION
This package makes it easy to run AWS Lambda Functions written in Perl.
=head2 Use Pre-built Public Lambda Layers
=over
=item 1
Login to your AWS Account and go to the Lambda Console.
=item 2
Create a new function and give it a name and an IAM Role.
=item 3
For the "Runtime" selection, select B<Provide your own bootstrap on Amazon Linux 2>.
=item 4
In the "Designer" section of your function dashboard, select the B<Layers> box.
=item 5
Scroll down to the "Layers" section and click B<Add a layer>.
=item 6
Select the B<Provide a layer version ARN> option, then copy/paste the Layer ARN for your region.
=item 7
Click the B<Add> button.
=item 8
Click B<Save> in the upper right.
=item 9
Upload your code and start using Perl in AWS Lambda!
=back
You can get the layer ARN in your script by using C<get_layer_info>.
use AWS::Lambda;
my $info = AWS::Lambda::get_layer_info_al2023(
"5.38", # Perl Version
"us-east-1", # Region
"x86_64", # Architecture ("x86_64" or "arm64", optional, the default is "x86_64")
);
say $info->{runtime_arn}; # arn:aws:lambda:us-east-1:445285296882:layer:perl-5-38-runtime-al2023-x86_64:1
say $info->{runtime_version}; # 1
say $info->{paws_arn} # arn:aws:lambda:us-east-1:445285296882:layer:perl-5-38-paws-al2023-x86_64:1
say $info->{paws_version} # 1,
Or, you can use following one-liner.
perl -MAWS::Lambda -e 'AWS::Lambda::print_runtime_arn_al2023("5.38", "us-east-1")'
perl -MAWS::Lambda -e 'AWS::Lambda::print_paws_arn_al2023("5.38", "us-east-1")'
The list of all layer ARNs is available on L<AWS::Lambda::AL2023>.
=head2 Use Pre-built Zip Archives
=over
=item 1
Login to your AWS Account and go to the Lambda Console.
=item 2
Create a new layer and give it a name.
=item 3
For the "Code entry type" selection, select B<Upload a file from Amazon S3>.
=item 4
In the "License" section, input L<https://github.com/shogo82148/p5-aws-lambda/blob/main/LICENSE>.
=item 5
Click B<Create> button.
=item 6
Use the layer created. For detail, see Use Prebuilt Public Lambda Layer section.
=back
URLs for Zip archives are here.
C<https://shogo82148-lambda-perl-runtime-$REGION.s3.amazonaws.com/perl-$VERSION-runtime-al2023-$ARCHITECTURE.zip>
=head2 Use Pre-built Docker Images
Prebuilt Docker Images based on L<https://gallery.ecr.aws/lambda/provided> are available.
You can pull from L<https://gallery.ecr.aws/shogo82148/p5-aws-lambda> or L<https://hub.docker.com/r/shogo82148/p5-aws-lambda>,
build your custom images and deploy them to AWS Lambda.
Here is an example of Dockerfile.
FROM shogo82148/p5-aws-lambda:base-5.38.al2023
# or if you want to use ECR Public.
# FROM public.ecr.aws/shogo82148/p5-aws-lambda:base-5.38.al2023
COPY handler.pl /var/task/
CMD [ "handler.handle" ]
( run in 0.704 second using v1.01-cache-2.11-cpan-437f7b0c052 )