This repository provides the Perl5 layer for AWS Lambda with runtime API.
arn:aws:lambda:${REGION}:652718333417:layer:perl-5_26-layer:1
arn:aws:lambda:${REGION}:652718333417:layer:perl-5_28-layer:1
- ap-northeast-1
- ap-northeast-2
- ap-south-1
- ap-southeast-1
- ap-southeast-2
- ca-central-1
- eu-central-1
- eu-west-1
- eu-west-2
- eu-west-3
- sa-east-1
- us-east-1
- us-east-2
- us-west-1
- us-west-2
If you want to build a layer and use that instead of provided layer, please follow the following sequence.
$ make build-docker-image PERL_VERSION=x.x.x CONTAINER_TAG=x.x
$ make build CONTAINER_TAG=x.x
NOTE: x.x.x
and x.x
means perl runtime version (e.g. 5.28.1
and 5.28
). You can specify as you like.
Then this command stats to create a zip archive as lambda-layer-perl-x.x.zip
.
--
Or you can use pre-built docker container (RECOMMENDED!):
$ make build CONTAINER_TAG=x.x DOCKER_HUB_ACCOUNT='moznion/'
Please refer to the following so that getting available containers: https://hub.docker.com/r/moznion/lambda-perl-layer-foundation/
aws --region "$REGION" --profile "$PROFILE" lambda publish-layer-version \
--layer-name "perl-x.x" \
--zip-file "fileb://lambda-layer-perl-x.x.zip"
Please refer: moznion/aws-lambda-perl5-layer-example
If you register the handler as handler.handle
, you have to write code into handler.pl
file and it must have handle
subroutine.
An simple example is below (handler.pl
):
#!perl
use strict;
use warnings;
use utf8;
sub handle {
my ($payload) = @_;
# do something
...
# if you want to finish the execution as failed, please die
# NOTE: must return hashref or arrayref
return +{
'msg' => 'OK',
'this is' => 'example',
};
}
1; # must return TRUE value here!
And there is necessary to publish the function with layer information. Please refer to the following example: How to publish a function
You have to build a function zip with the perl runtime that is the same version as Lambda's one.
Please refer: https://github.com/moznion/aws-lambda-perl5-layer-example/tree/master/simple
Probably this because of the Lambda runtime environment (i.e. base Linux).
This lambda applies workaround that includes those missing shared libraries.
Ref:
- #6
- https://github.com/moznion/aws-lambda-perl5-layer/commit/833ded09dd460ccba08bd4e176a9bc99ff4ec7e1
However, I think this way is a little bit fragile... is there any good method?
$ make build-docker-image PERL_VERSION=x.x.x CONTAINER_TAG=x.x
$ make publish-docker-image CONTAINER_TAG=x.x DOCKER_ID_USER=xxx
$ make build-docker-image PERL_VERSION=x.x.x CONTAINER_TAG=x.x OPT='--no-cache'
moznion ([email protected])
The MIT License (MIT)
Copyright © 2018 moznion, http://moznion.net/ <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.