Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
A utility to bundle python code and/or dependencies for deployment to AWS Lambda
Readme
Lambda Bundler helps you package your python lambda functions and their dependencies for deployment to AWS.
It supports three different modes:
Dependencies will be cached if possible in order to provide a fast build experience.
The installation is very simple using pip:
pip install lambda-bundler
from lambda_bundler import build_layer_package
path_to_deployment_artifact = build_layer_package(
# You can install the dependencies from multiple
# requirement files into a single layer
requirement_files=[
"path/to/requirements.txt"
]
)
# path_to_deployment_artifact now points to a zip archive with the dependencies.
from lambda_bundler import build_lambda_package
path_to_deployment_artifact = build_lambda_package(
code_directories=[
"path/to/package",
"path/to/other/package
],
exclude_patterns=[
"*.pyc"
]
)
# path_to_deployment_artifact now contains the path to the zip archive
If you'd like to package your dependencies directly into the deployment artifact you can do that very easily. Please keep in mind, that the size limit for a zipped deployment package is 50MB according to the documentation and the content of packages larger than 3MB won't be visible in the code editor in the console.
from lambda_bundler import build_lambda_package
path_to_deployment_artifact = build_lambda_package(
code_directories=[
"path/to/package",
"path/to/other/package
],
requirement_files=[
"path/to/requirements.txt
],
exclude_patterns=[
"*.pyc"
]
)
# path_to_deployment_artifact now contains the path to the zip archive
The library uses a working directory to build and cache packages.
By default this is located in the lambda_bundler_builds
folder in your temporary directory as determined by python.
If you'd like to change that, you can set the LAMBDA_BUNDLER_BUILD_DIR
environment variable and point it to another directory.
If you're using the Cloud Development Kit and just want to do a cdk synth
to check your infrastructure code without actually deploying it, you can set the environment variable LAMBDA_BUNDLER_SKIP_INSTALL
to true
. This will skip installing dependencies and bundling the code, which makes the process a lot faster - although it won't work when you try to deploy it with the variable set to true
.
For an example of how to use this, I suggest you check out the demo repository which includes a CDK app that deploys three lambda functions with dependencies of different sizes. If you take a closer look at the build pipeline you'll see, how effective the caching is.
FAQs
A utility to bundle python code and/or dependencies for deployment to AWS Lambda
We found that lambda-bundler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).