Skip to main content

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.

Metadata

Release files for aws_pylambda_sam_builder 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws_pylambda_sam_builder 0.2.4
File Size Uploaded
aws_pylambda_sam_builder-0.2.4.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws_pylambda_sam_builder 0.2.4
File Interpreter ABI Platform
aws_pylambda_sam_builder-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / aws_pylambda_sam_builder-0.2.4.tar.gz

Download URL aws_pylambda_sam_builder-0.2.4.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9f9027cf5436a7c1e550e3e0103572f7ff5a718c6eb7167998c586038272470d
BLAKE2b-256 checksum
How to use checksums
21382be89625c19d756134fabf20cd711e8fc78d040a1d768a2ed517144de387
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.11.11 Darwin/23.5.0

Release files / aws_pylambda_sam_builder-0.2.4-py3-none-any.whl

Download URL aws_pylambda_sam_builder-0.2.4-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
242bc5ad716c5b24b8756d4753a8f470c4d9613d6e29bad83adf80682e983f9b
BLAKE2b-256 checksum
How to use checksums
db9aeccae1ced3265d6c137df021f54ca6674ef79e935dabb31982a124453f95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.11.11 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page