Skip to main content

A tool for building AWS Lambda functions from Python projects.

Project description

AWS Python Lambda SAM Builder

Like https://github.com/serverless/serverless-python-requirements but much simpler and for AWS SAM.

Speeds up cross-building for x86_64 on ARM64 by using a local cache.

Usage

Put a Makefile (SAM requires capital M and a make target that matches the logical resources name) in your lambda function top dir:

install-builder:
	@python -c "import aws_pylambda_sam_builder" || @pip install aws_pylambda_sam_builder

.PHONY: build-YourLambda
build-YourLambda: install-builder
	@python -m aws_pylambda_sam_builder --aws-runtime py311 --aws-architecture x86_64 --source ./ --destination $(ARTIFACTS_DIR)

Set your SAM config to build with Makefile:

Resources:
  YourLambda:
    Metadata:
      BuildMethod: makefile

Now sam build --build-in-source --parallel -t template.yaml YourLambda uses per-package caching, doesn't need a container, and builds in 100ms after the first build.

Issues

  • probably not safe for concurrent builds
  • can't build from source (only does binary wheels)
  • requires all transitive deps to be listed in requirements.txt. I did poetry export -f initial_requirements.txt -o requirements.txt --without-hashes

New in 0.2

  • Support for AWS Lambda python 3.13 environment
  • File lock for concurrent builds
  • Bugfix: previously, if a download failed, e.g. because no compiled package existed, a folder with the metadata hash would still be created. Then the next run would "succeed", but the dependency would not end up in the lambda zip. Current version makes sure to crash and delete the folder if downloading fails.

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

aws_pylambda_sam_builder-0.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_pylambda_sam_builder-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file aws_pylambda_sam_builder-0.2.0.tar.gz.

File metadata

  • Download URL: aws_pylambda_sam_builder-0.2.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Darwin/23.5.0

File hashes

Hashes for aws_pylambda_sam_builder-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f68243851a5e4e6746d62597d710af52ff7b66a2920dd69d6dc05000fdf7b4f4
MD5 f5549a6e85e618a226224ff2ee1ef5f3
BLAKE2b-256 7eae767b6f6d58b5a4fae7bd0e86c64ef1c0a06a7e9db0b2f55320dbdcf7b98d

See more details on using hashes here.

File details

Details for the file aws_pylambda_sam_builder-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_pylambda_sam_builder-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c82604240a8305be538235ed91da9dba5c8024b3f192fbf435396bf1226ba1f3
MD5 8d34816ac8af77a7cddd57200da0acec
BLAKE2b-256 f28b4b172fd41ed414b5e0e09235886d1524fe3211f32c835e9f7e2e438572f9

See more details on using hashes here.

Supported by

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