Skip to main content

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

samwich_cli-0.10.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

samwich_cli-0.10.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file samwich_cli-0.10.0.tar.gz.

File metadata

  • Download URL: samwich_cli-0.10.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.12

File hashes

Hashes for samwich_cli-0.10.0.tar.gz
Algorithm Hash digest
SHA256 3a97ca1d512b8be2227d502201bba9efb13f8e1ac43f9cde0cf7bc878d0b899c
MD5 9557dc706a499e1da5d45bbbdcae5280
BLAKE2b-256 ddda4c1814f3e87887a116d35a85539f6cc60cd384e3d48b5a31e38bd9a90312

See more details on using hashes here.

File details

Details for the file samwich_cli-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for samwich_cli-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5e18a2cb86677858b61d479d20f868c2982ade005869e6e975df3010582d049
MD5 9a970f8c272737100448303dbba79ac9
BLAKE2b-256 a5e7d47a4fdd20f2143b04a054f12424421570c2c1c0f4fd2e67009f2ec22158

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page