
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
A tool to package Python AWS Lambda functions with zips, Docker containers, and layers.
lambda-packer
is a command-line tool designed to simplify the process of packaging Python AWS Lambda functions.
It provides an opinionated approach to develop Lambdas using a monorepo, allowing packaging as either zip files or Docker containers,
with shared dependencies packaged as Lambda layers.
pip install lambda-packer
The init
command creates a basic repository structure for your Lambda functions, including a common
folder for shared dependencies, an example Lambda function, and a package_config.yaml
file.
lambda-packer init <parent_directory> --lambda-name <lambda_name>
Example:
lambda-packer init my_project --lambda-name my_lambda
This command creates:
my_project/
āāā common/
āāā my_lambda/
ā āāā lambda.py
ā āāā requirements.txt
āāā dist/
āāā package_config.yaml
The package_config.yaml
file is where you define how to package your Lambdas. You can specify the type of packaging (zip
or docker
), the Python runtime, and any layers associated with the Lambda.
package_config.yaml
lambdas:
my_lambda:
type:
- zip
file_name: lambda
function_name: lambda_handler
runtime: '3.12'
platforms: ['linux/arm64', 'linux/x86_64']
layers:
- common
To package a Lambda function (for a zip
type Lambda), use the following command:
lambda-packer package my_lambda
This will package the Lambda function and any referenced layers (e.g., common
) into a zip file in the dist
directory.
To package a Lambda as a Docker container (for a docker
type Lambda), modify the package_config.yaml
and set type: docker
.
lambdas:
my_lambda:
type: docker
runtime: "3.9"
layers:
- common
Then run:
lambda-packer package my_lambda
Or package them all:
layer-packer package
The tool will build a Docker image using the specified Python runtime and package the Lambda function.
If you need to package shared dependencies (like the common
folder) as Lambda layers, you can use the package-layer
command:
lambda-packer package-layer common
This command packages the common
directory as a Lambda layer and zips it to the dist/
folder.
init <parent_directory> --lambda-name <lambda_name>
: Initialize a new monorepo with a common folder, a lambda, and package_config.yaml
.package <lambda_name>
: Package the specified Lambda function (either as zip or Docker container).package-layer <layer_name>
: Package a specific layer (e.g., common
) into a zip file.config <lambda_name>
: Generate a package_config.yaml from an existing monorepo.clean
: Clean the dist/
directory by removing all contents.lambda-packer init my_project --lambda-name my_lambda
package_config.yaml
to configure the Lambda:lambdas:
my_lambda:
type: zip
runtime: "3.9"
layers:
- common
Install dependencies for my_lambda
by editing my_lambda/requirements.txt
.
Package the Lambda:
lambda-packer package my_lambda
common
layer (if needed):lambda-packer package-layer common
You can add a new Lambda to an existing repository using the lambda
command. You can also specify layers to be added to the new Lambda.
lambda-packer lambda <lambda_name> --runtime <runtime_version> --type <zip|docker> --layers <layer1> --layers <layer2>
Example:
lambda-packer lambda my_new_lambda --runtime 3.9 --type docker --layers common --layers shared
This will create a new Lambda directory and update the package_config.yaml
like so:
lambdas:
my_new_lambda:
runtime: "3.9"
type: docker
layers:
- common
- shared
If no layers are specified, the layers
key will not be added.
Example without layers:
lambda-packer lambda my_new_lambda --runtime 3.9 --type docker
This will update the package_config.yaml
like this:
lambdas:
my_new_lambda:
runtime: "3.9"
type: docker
Contributions are welcome! If you'd like to contribute to this project, please open a pull request or issue on GitHub.
Clone this repository and run:
git clone https://github.com/calvernaz/lambda-packer.git
cd lambda-packer
pip install -e .
For development:
pip install -e .[dev]
pytest tests/
Bump patch version:
bumpversion patch
Push tags:
git push origin main --tags
This project is licensed under the MIT License.
For any questions or feedback, feel free to open an issue on GitHub.
FAQs
A tool to package Python AWS Lambda functions with zips, Docker containers, and layers.
We found that lambda-packer 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.