Skip to main content

SAMWICH CLI

A 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.

Table of Contents

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:

  1. Copies your requirements.txt file to the appropriate locations for Lambda functions and layers.
  2. Executes sam build to build your AWS resources.
  3. 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 to template.yaml in the current directory.
  • --requirements: Path to your Python requirements.txt file. Defaults to requirements.txt in 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 to sam 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:

  • ruff for linting and formatting
  • pycln for removing unused imports
  • Various pre-commit hooks for file consistency

Metadata

Release files for samwich-cli 0.18.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for samwich-cli 0.18.0
File Size Uploaded Provenance Actions
samwich_cli-0.18.0.tar.gz 8.2 kB Without provenance Details for samwich_cli-0.18.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for samwich-cli 0.18.0
File Interpreter ABI Platform Actions
samwich_cli-0.18.0-py3-none-any.whl Python 3 none any Details for samwich_cli-0.18.0-py3-none-any.whl

Total release size: 18.3 kB

Release files / samwich_cli-0.18.0.tar.gz

Download URL samwich_cli-0.18.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
126f0b26dc0b61aa656cfb125f664db1e5e680c3ee486d129ae7d413085cfe71
BLAKE2b-256 checksum
How to use checksums
2078c54937c787426aac763d989086bcf40c2a24967e56ce98f6ca14a1c0b83b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.22

Release files / samwich_cli-0.18.0-py3-none-any.whl

Download URL samwich_cli-0.18.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5b9faa0281f088824b90c56ed9be4962052ab933057d66a9f3201ad2c202e15
BLAKE2b-256 checksum
How to use checksums
e55c8379d3e66c902f82a56b79a21fa5cd8501fe408c5eeec1025d4484d82003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.22

Security for samwich-cli 0.18.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page