A CLI tool to streamline AWS SAM deployments for Python Lambda functions by managing dependencies, executing sam build, and maintaining consistent folder structures.
Project description
SAMWICH CLI
A sandwich :sandwich: for sam build
SAMWICH CLI is a tool that simplifies working with AWS Serverless Application Model (SAM) deployments, particularly focusing on dependency management and build processes for Python Lambda functions and layers.
Note: This project is in early development and may not be fully functional.
Table of Contents
- Inspiration
- Installation
- Requirements
- Features
- Basic Usage
- Examples and Advanced Usage
- License
- Contributing
- Development
- Code Quality
Inspiration
Many python projects do not use requirements.txt files, but instead use pyproject.toml with poetry or uv. This tool is designed to help those projects by copying the generated requirements.txt to the appropriate locations for AWS Lambda functions and layers.
Also, using absolute python imports from the project root is not currently possible with AWS SAM (see https://github.com/aws/aws-sam-cli/issues/6593). This tool helps to maintain a consistent folder structure for your functions and layers, so the lambda functions can be individually packaged with the same folder structure as they are developed.
Installation
pipx install samwich-cli
Requirements
- Python 3.9 or higher
Features
The SAMWICH CLI:
- Copies your
requirements.txtfile to the appropriate locations for Lambda functions and layers. - Executes
sam buildto build your AWS resources. - Updates the folder structure of your functions and layers to maintain consistency.
Basic Usage
samwich-cli --requirements requirements.txt --template-file template.yaml
Options
--template-file: Path to yours AWS SAM template file. Defaults totemplate.yamlin the current directory.--requirements: Path to your Python requirements.txt file. Defaults torequirements.txtin the current directory.--workspace-root: Path to the workspace root.--source-dir: Path to the source directory for the code. When restructuring, only the child paths of this directory will be included.--sam-args: Additional arguments to pass tosam build. For example,--sam-args "--debug --use-container".--debug: Enable debug logging
Environment Variables
All options can also be set using environment variables. The environment variable names are the same as the option names, but prefixed with SAMWICH, in uppercase, and with underscores instead of dashes. For example, --template-file can be set using the SAMWICH_TEMPLATE_FILE environment variable.
Examples and Advanced Usage
Open the docs folder for examples and detailed usage.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development
Refer to the Justfile for development tasks. It is recommended to pipx install rust-just to run the tasks but you can also copy the commands from the Justfile and run them manually.
Code Quality
This project uses pre-commit hooks for code quality, including:
rufffor linting and formattingpyclnfor removing unused imports- Various
pre-commithooks for file consistency
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 samwich_cli-0.8.0.tar.gz.
File metadata
- Download URL: samwich_cli-0.8.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb1ecc93a76d57e77a147db3ee4251f553a17a4a0d8f3cc6585c0483f3f7f3c4
|
|
| MD5 |
c1b389d05148d6b49171fd06b4f42c0a
|
|
| BLAKE2b-256 |
e9b9bbcd78e6ba6e0a7de51a9c1d442e58653c173fde838a99b11a0cd1e07c41
|
File details
Details for the file samwich_cli-0.8.0-py3-none-any.whl.
File metadata
- Download URL: samwich_cli-0.8.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21e26f9ecdabf725423f7687ee6edb65d9658d73c2eb9713a38ad3ba0caa2261
|
|
| MD5 |
30b2b7f8bf4917c60a36d582c3101f6e
|
|
| BLAKE2b-256 |
f1de643531abcb14609f77e28d490082a53d3c2680501ea18ca24c132e3e03f0
|