Skip to main content

The plugin for poetry that allows you to build zip packages suited for serverless deployment like AWS Lambda, Google App Engine, Azure App Service, and more...

Project description

Poetry Plugin Lambda Build

The plugin for poetry that allows you to build zip packages suited for serverless deployment like AWS Lambda, Google App Engine, Azure App Service, and more...

Additionally it provides docker container support for build inside container

Installation

poetry self add poetry-plugin-lambda-build
poetry self add poetry-plugin-export

Execution

Configure pyproject.toml with the following configuration. This is example for AWS Lambda configuration

[tool.poetry-plugin-lambda-build]
docker_image = "public.ecr.aws/sam/build-python3.11:latest-x86_64"
docker_network = "host"
layer_artifact_name = "artifacts/layer.zip"
layer_install_dir = "lambda/python"
handler_artifact_name = "artifacts/handler.zip"

Running ...

poetry build-lambda

will build handler and layer packages for AWS Lambda deployment inside public.ecr.aws/sam/build-python3.11:latest-x86_64 container.

artifacts
├── handler.zip
└── layer.zip

Configuration Examples

AWS Lambda - all in one - dependencies and handler in the same zip package - Default

[tool.poetry-plugin-lambda-build]
artifact_name = "package.zip"

AWS Lambda - all in one - layer package

[tool.poetry-plugin-lambda-build]
install_dir = "lambda/python"
artifact_name = "layer.zip"

AWS Lambda - separated - separate layer package and handler package

[tool.poetry-plugin-lambda-build]
layer_artifact_name = "layer.zip"
layer_install_dir = "lambda/python"
handler_artifact_name = "handler.zip"

AWS Lambda - separated - separate layer package and handler package build in docker container

[tool.poetry-plugin-lambda-build]
docker_image = "public.ecr.aws/sam/build-python3.11:latest-x86_64"
docker_network = "host"
layer_artifact_name = "layer.zip"
layer_install_dir = "lambda/python"
handler_artifact_name = "handler.zip"

Tips

Mac users with Docker Desktops

Make sure to configure DOCKER_HOST properly

export DOCKER_HOST=unix:///Users/$USER/.docker/run/docker.sock

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry_plugin_lambda_build-0.1.7.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page