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 --cached -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

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.1.0.tar.gz (4.5 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.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aws_pylambda_sam_builder-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 439fd2403ddccefcf61091f9b14872cf8f8ebd8c571f3dad13b226a84d9a3776
MD5 bb0d97c8f5440b85ae1df82e02117ba3
BLAKE2b-256 0de0692a72924e3b94a07ffa42ceb8af9cdcf0d17ceff3d5509fb9f7234c524d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aws_pylambda_sam_builder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a47592caebb7b144d9ee09e78d4d16d27b79758bfc51f468b21bb60e43723e38
MD5 55a10d8ad72978743266dfb385f21a25
BLAKE2b-256 f7ebbfb0b2ecb2ec6c0c9cc427051f3c8f7a83ff75c7f6d9fffab47a94992b9b

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