AWS-Lambda
view release on metacpan or search on metacpan
[](https://github.com/shogo82148/p5-aws-lambda/actions?workflow=Test)
# NAME
AWS::Lambda - Perl support for AWS Lambda Custom Runtime.
# SYNOPSIS
Save the following Perl script as `handler.pl`.
sub handle {
my ($payload, $context) = @_;
return $payload;
}
1;
and then, zip the script.
$ zip handler.zip handler.pl
Finally, create new function using awscli.
$ aws --region "$REGION" --profile "$PROFILE" lambda create-function \
--function-name "hello-perl" \
--zip-file "fileb://handler.zip" \
--handler "handler.handle" \
--runtime provided.al2023 \
--role arn:aws:iam::xxxxxxxxxxxx:role/service-role/lambda-custom-runtime-perl-role \
--layers "arn:aws:lambda:$REGION:445285296882:layer:perl-5-38-runtime-al2023-x86_64:1"
It also supports [response streaming](https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html).
sub handle {
my ($payload, $context) = @_;
return sub {
my $responder = shift;
my $writer = $responder->('application/json');
$writer->write('{"foo": "bar"}');
$writer->close;
};
}
# DESCRIPTION
This package makes it easy to run AWS Lambda Functions written in Perl.
## Use Pre-built Public Lambda Layers
1. Login to your AWS Account and go to the Lambda Console.
2. Create a new function and give it a name and an IAM Role.
3. For the "Runtime" selection, select **Provide your own bootstrap on Amazon Linux 2**.
4. In the "Designer" section of your function dashboard, select the **Layers** box.
5. Scroll down to the "Layers" section and click **Add a layer**.
6. Select the **Provide a layer version ARN** option, then copy/paste the Layer ARN for your region.
7. Click the **Add** button.
8. Click **Save** in the upper right.
9. Upload your code and start using Perl in AWS Lambda!
You can get the layer ARN in your script by using `get_layer_info`.
use AWS::Lambda;
my $info = AWS::Lambda::get_layer_info_al2023(
( run in 1.184 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )