This example provides a plack application example of aws-lambda-perl5-layer for building and packing a Lambda function.
- Register a Lambda handler as
handler.handle
- write a function to
handler.pl
(this must havehandle
subroutine) andapp.psgi
- arrange the dependency
- please edit
cpanfile
- please edit
- build it
- upload the built zip archive
$ make build CONTAINER_TAG=x.x
x.x
is the version of the perl runtime (e.g. 5.26
, 5.28
).
You must build it with the same version to the layer's perl version.
aws --profile "$PROFILE" --region "$REGION" lambda create-function \
--function-name 'plack-app' \
--runtime 'provided' \
--role "$YOUR_ROLE_ARN" \
--handler 'handler.handle' \
--layers "arn:aws:lambda:${REGION}:${AWS_ACCOUNT}:layer:perl-${PERL_VERSION}-layer:1" \
--zip-file 'fileb://func.zip'
Following processes are executed on the Docker container (Highly recommend: you should use moznion/lambda-perl-layer-foundation).
- build the perl runtime with specified version
- vendor the dependencies by Carton
- zip components
See: build.sh
MIT