AWS-Lambda

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - support streaming response

0.1.2 2023-08-05T22:22:19Z
    - bump Mozilla::CA 20230801
    - install Carton

0.1.1 2023-08-01T13:32:15Z
    - ap-south-2, ap-southeast-4, eu-central-2, eu-south-2 and il-central-1 are available.

0.1.0 2023-07-31T11:31:41Z
    - switch build environment from lambci/lambda based to public.ecr.aws/lambda/provided based.
    - stop building Amazon Linux 2 based layers.
        - These layers are still available however they will not receive any updates.

0.0.40 2023-07-09T17:55:20Z
    - Perl 5.38.0 is released
    - Perl 5.36.1 is released

0.0.39 2022-11-20T18:56:48Z
    - update dependency modules

README.md  view on Meta::CPAN

## Use Pre-built Docker Images

Prebuilt Docker Images based on [https://gallery.ecr.aws/lambda/provided](https://gallery.ecr.aws/lambda/provided) are available.
You can pull from [https://gallery.ecr.aws/shogo82148/p5-aws-lambda](https://gallery.ecr.aws/shogo82148/p5-aws-lambda) or [https://hub.docker.com/r/shogo82148/p5-aws-lambda](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" ]

Build the hello-perl container image locally:

    $ docker build -t hello-perl .

To check if this is working, start the container image locally using the Lambda Runtime Interface Emulator:

    $ docker run -p 9000:8080 hello-perl:latest

README.md  view on Meta::CPAN

URLs for Zip archive are:

`https://shogo82148-lambda-perl-runtime-$REGION.s3.amazonaws.com/perl-$VERSION-paws-al2-$ARCHITECTURE.zip`

## Use Prebuilt Docker Images for Paws

use the `base-$VERSION-paws.al2023` tag on [https://gallery.ecr.aws/shogo82148/p5-aws-lambda](https://gallery.ecr.aws/shogo82148/p5-aws-lambda) or [https://hub.docker.com/r/shogo82148/p5-aws-lambda](https://hub.docker.com/r/shogo82148/p5-aws-lambda).

    FROM shogo82148/p5-aws-lambda:base-5.38-paws.al2023
    # or if you want to use ECR Public.
    # FROM public.ecr.aws/shogo82148/p5-aws-lambda:base-5.38-paws.al2023
    COPY handler.pl /var/task/
    CMD [ "handler.handle" ]

## Run in Local using Docker for Paws

use the `build-$VERSION-paws.al2023` and `$VERSION-paws.al2023` tag on [https://gallery.ecr.aws/shogo82148/p5-aws-lambda](https://gallery.ecr.aws/shogo82148/p5-aws-lambda) or [https://hub.docker.com/r/shogo82148/p5-aws-lambda](https://hub.docker.com/...

    # Install the dependency.
    docker run --rm -v $(PWD):/var/task shogo82148/p5-aws-lambda:build-5.38-paws.al2023 \
        cpanm --notest --local-lib extlocal --no-man-pages --installdeps .

author/build-paws-layer-al2.sh  view on Meta::CPAN

    "arm64") DOCKER_PLATFORM=linux/arm64;;
    *) echo "unknown platform: $PLATFORM";
    exit 1;;
esac

docker run \
    -v "$ROOT:/var/task" \
    -v "$OPT-$PLATFORM/lib/perl5/site_perl:/opt/lib/perl5/site_perl" \
    -v "$OPT-$PLATFORM/lib:/opt-lib" \
    --platform "$DOCKER_PLATFORM" \
    "public.ecr.aws/sam/build-provided.al2:1-$PLATFORM" \
    ./author/build-paws-al2.sh "$TAG"

find "$OPT-$PLATFORM" -type f -a -name '*.pm' -print0 | parallel -0 -j 32 "$ROOT/author/perlstrip.sh"

cd "$OPT-$PLATFORM"
mkdir -p "$DIST"
zip -9 -r "$DIST/perl-$TAG-paws-al2-$PLATFORM.zip" .

author/build-paws-layer-al2023.sh  view on Meta::CPAN

    "arm64") DOCKER_PLATFORM=linux/arm64;;
    *) echo "unknown platform: $PLATFORM";
    exit 1;;
esac

docker run \
    -v "$ROOT:/var/task" \
    -v "$OPT-$PLATFORM/lib/perl5/site_perl:/opt/lib/perl5/site_perl" \
    -v "$OPT-$PLATFORM/lib:/opt-lib" \
    --platform "$DOCKER_PLATFORM" \
    "public.ecr.aws/sam/build-provided.al2023:1-$PLATFORM" \
    ./author/build-paws-al2023.sh "$TAG"

find "$OPT-$PLATFORM" -type f -a -name '*.pm' -print0 | parallel -0 -j 32 "$ROOT/author/perlstrip.sh"

cd "$OPT-$PLATFORM"
mkdir -p "$DIST"
zip -9 -r "$DIST/perl-$TAG-paws-al2023-$PLATFORM.zip" .

author/build-perl-runtime-al2.sh  view on Meta::CPAN

    "arm64") DOCKER_PLATFORM=linux/arm64;;
    *) echo "unknown platform: $PLATFORM";
    exit 1;;
esac

# build the perl binary
docker run \
    -v "$ROOT:/var/task" \
    -v "$OPT-$PLATFORM:/opt" \
    --rm --platform "$DOCKER_PLATFORM" \
    "public.ecr.aws/sam/build-provided.al2:1-$PLATFORM" \
    ./author/build-perl-al2.sh "$PERL_VERSION"

# sanity check the perl binary works on the emulation images
docker run \
    -v "$OPT-$PLATFORM:/opt" \
    --rm --platform "$DOCKER_PLATFORM" \
    --entrypoint /opt/bin/perl \
    "public.ecr.aws/lambda/provided:al2-$PLATFORM" \
    -MJSON::XS -MYAML::XS -MNet::SSLeay -MIO::Socket::SSL -MMozilla::CA \
    -MAWS::XRay -MAWS::Lambda -MAWS::Lambda::PSGI -e ''

# create zip archive
cd "$OPT-$PLATFORM"
mkdir -p "$DIST"
zip -9 -r "$DIST/perl-$TAG-runtime-al2-$PLATFORM.zip" .

author/build-perl-runtime-al2023.sh  view on Meta::CPAN

    "arm64") DOCKER_PLATFORM=linux/arm64;;
    *) echo "unknown platform: $PLATFORM";
    exit 1;;
esac

# build the perl binary
docker run \
    -v "$ROOT:/var/task" \
    -v "$OPT-$PLATFORM:/opt" \
    --rm --platform "$DOCKER_PLATFORM" \
    "public.ecr.aws/sam/build-provided.al2023:1-$PLATFORM" \
    ./author/build-perl-al2023.sh "$PERL_VERSION"

# sanity check the perl binary works on the emulation images
docker run \
    -v "$OPT-$PLATFORM:/opt" \
    --rm --platform "$DOCKER_PLATFORM" \
    --entrypoint /opt/bin/perl \
    "public.ecr.aws/lambda/provided:al2023-$PLATFORM" \
    -MJSON::XS -MYAML::XS -MNet::SSLeay -MIO::Socket::SSL -MMozilla::CA \
    -MAWS::XRay -MAWS::Lambda -MAWS::Lambda::PSGI -e ''

# create zip archive
cd "$OPT-$PLATFORM"
mkdir -p "$DIST"
zip -9 -r "$DIST/perl-$TAG-runtime-al2023-$PLATFORM.zip" .

author/cfn-s3.yml  view on Meta::CPAN

Resources:
  LayerBucket:
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Sub shogo82148-lambda-perl-runtime-${AWS::Region}
      VersioningConfiguration:
        Status: Enabled

      # allow public access policy to the bucket
      PublicAccessBlockConfiguration:
        BlockPublicAcls: true
        BlockPublicPolicy: false
        IgnorePublicAcls: true
        RestrictPublicBuckets: false
      OwnershipControls:
        Rules:
          - ObjectOwnership: BucketOwnerEnforced

  # make the Perl Layers public readable
  S3BucketPolicy:
    Type: AWS::S3::BucketPolicy
    Properties:
      Bucket: !Ref LayerBucket
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal: "*"
            Action: "s3:GetObject"

examples/docker/Dockerfile  view on Meta::CPAN

FROM shogo82148/p5-aws-lambda:base-5.32-paws.al2
# or if you want to use ECR Public.
# FROM public.ecr.aws/shogo82148/p5-aws-lambda:base-5.32-paws.al2
COPY handler.pl /var/task/
CMD [ "handler.handle" ]

lib/AWS/Lambda.pm  view on Meta::CPAN

=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" ]

Build the hello-perl container image locally:

    $ docker build -t hello-perl .

To check if this is working, start the container image locally using the Lambda Runtime Interface Emulator:

    $ docker run -p 9000:8080 hello-perl:latest

lib/AWS/Lambda.pm  view on Meta::CPAN

URLs for Zip archive are:

C<https://shogo82148-lambda-perl-runtime-$REGION.s3.amazonaws.com/perl-$VERSION-paws-al2-$ARCHITECTURE.zip>

=head2 Use Prebuilt Docker Images for Paws

use the C<base-$VERSION-paws.al2023> tag on L<https://gallery.ecr.aws/shogo82148/p5-aws-lambda> or L<https://hub.docker.com/r/shogo82148/p5-aws-lambda>.

    FROM shogo82148/p5-aws-lambda:base-5.38-paws.al2023
    # or if you want to use ECR Public.
    # FROM public.ecr.aws/shogo82148/p5-aws-lambda:base-5.38-paws.al2023
    COPY handler.pl /var/task/
    CMD [ "handler.handle" ]

=head2 Run in Local using Docker for Paws

use the C<build-$VERSION-paws.al2023> and C<$VERSION-paws.al2023> tag on L<https://gallery.ecr.aws/shogo82148/p5-aws-lambda> or L<https://hub.docker.com/r/shogo82148/p5-aws-lambda>.

    # Install the dependency.
    docker run --rm -v $(PWD):/var/task shogo82148/p5-aws-lambda:build-5.38-paws.al2023 \
        cpanm --notest --local-lib extlocal --no-man-pages --installdeps .



( run in 0.520 second using v1.01-cache-2.11-cpan-64827b87656 )