Build and deploy Lambda function with optional S3 integration using simple config
Project description
LambdaMaker
LambdaMaker is a simple, modular Python utility that automates the creation, packaging, configuration, and deployment of AWS Lambda functions, especially those processing and/or triggered from s3, using only standard Python and boto3.
🚀 Features
- Package Python-based Lambda functions from local code and dependencies
- Create an IAM role with appropriate permissions
- Deploy the Lambda function to AWS
- Set environment variables from a
.envfile - Optionally configure S3 bucket triggers for Lambda execution
- Supports a JSON config file for consistent and repeatable deployment
📦 Installation
You can install LambdaMaker directly from PyPI:
pip install lambdamaker
⚙️ Requirements
LambdaMaker was developed and tested using Python 3.12, which is currently supported by AWS Lambda. However, the version can be configured (see python_version below).
- You must have valid AWS credentials configured in
~/.aws(viaaws configureor similar). - If using S3 triggers, the S3 bucket must already exist.
- Docker must be installed and running if
use_dockeris set totrue. If Docker Desktop is required, ensure it is manually started before running. - If
openai,pydantic, or other compiled dependencies are used, settinguse_dockeris strongly recommended.
🔧 Configuration
All routines look for config.json, requirements.txt, and my.env in the same working directory by default. You can override this by passing a working_dir parameter to any of the functions.
By default, any additional Python source files specified under mylib_files in the configuration will be copied from a directory named mylib in the user's home folder ($HOME/mylib). You may override this by passing the mylib_dir parameter with a different path.
If you're using the example project in the mylambda folder in this repository, you can run the tool using working_dir="mylambda" and mylib_dir="." to pick up helloworld.py from the same folder.
Common Parameters
replace(bool, default:False): IfTrue, existing AWS resources such as the Lambda function, IAM role, or S3 triggers will be updated or replaced. IfFalse, existing resources are left untouched.working_dir(Path or str, optional): Specifies the directory whereconfig.json,requirements.txt, andmy.envare located. Defaults to the current working directory.mylib_dir(Path or str, optional): Directory from which to copy the files listed undermylib_files. Defaults to$HOME/mylib.use_docker(bool, default:False): Enables Docker-based builds to ensure compatibility with AWS Lambda Linux environment, particularly for packages requiring native binaries. When set totrue, Docker must be running or the user will be prompted.python_version(str, default: "3.12"): Specifies the Python runtime for both Docker image used during zip creation and the AWS Lambda deployment.
Example config.json
{
"lambda_name": "s3lambda",
"entry_file": "helloworld.py",
"entry_func": "lambda_handler",
"mylib_files": ["helloworld.py"],
"output_dir": ".",
"memory_size": 128,
"timeout": 120,
"ephemeral_storage": 512,
"role_name": "s3lambda",
"s3_buckets": ["*"],
"trigger_bucket": null,
"trigger_filetypes": [],
"use_docker": false,
"python_version": "3.12"
}
- The
entry_filemust be either listed inmylib_filesor included in yourrequirements.txt. my.envuses standard.envfile format:
USERNAME=World
Environment variables defined here will be injected into your Lambda runtime.
✅ Example Usage
from lambdamaker import (
create_iam_role,
create_lambda_zip,
create_or_update_lambda,
configure_s3_trigger
)
create_iam_role()
create_lambda_zip()
create_or_update_lambda()
configure_s3_trigger()
Or call the main function:
from lambdamaker import main
main() # safer default: replace=False
To use the included sample from the /mylambda folder:
main(working_dir="mylambda", mylib_dir="mylambda")
🔐 IAM and Security
The tool will:
- Automatically create an IAM role if it doesn't exist
- Attach AWSLambdaBasicExecutionRole
- Optionally grant access to S3 buckets (full or restricted)
🙣 S3 Triggers
To enable S3 triggers:
- Set
trigger_bucketto a valid bucket name - Set
trigger_filetypesto a list of suffixes like[".json", ".mp4"]
The tool will:
- Add invoke permission for the bucket
- Create a trigger per suffix
- Preserve triggers for other Lambda functions on the bucket
📄 License
MIT License
Contributions and issue reports are welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lambdamaker-0.2.0.tar.gz.
File metadata
- Download URL: lambdamaker-0.2.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c609f91e23f73149467d95543f3c27f46acdfbcf0738e9175943b509dda3ad47
|
|
| MD5 |
4c8546b6d7f662ba1f6c21f805504cc5
|
|
| BLAKE2b-256 |
d9196cbd2b9b59a419c3d2207ead06bce1101f2abe6aecea3fc242545734e033
|
File details
Details for the file lambdamaker-0.2.0-py3-none-any.whl.
File metadata
- Download URL: lambdamaker-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da32e29489eff86882f1e2e56695419f109986fdc36940541a8f200d2c5c4f73
|
|
| MD5 |
4dd394d131c79097b45df44097de6e49
|
|
| BLAKE2b-256 |
6bc8c6b2d2515c49a18bbe52c58253cadfb48645940ec82d6d39dee64445ac11
|