Skip to main content

Python client for AWS Lambda middleware functions

Project description

Lambda Middleware

A Python client library for calling AWS Lambda functions. This package simplifies Lambda invocations by providing a clean, typed interface with full AWS integration.

Features

  • Simple API: Just instantiate LambdaMiddleware and call methods
  • Flexible Configuration: Environment variables or programmatic configuration
  • CLI Interface: Invoke Lambda functions from the command line
  • Type Safe: Full type hints with Pydantic validation
  • AWS Integration: Built on boto3 for seamless AWS authentication

Installation

Install via pip or uv:

pip install lambda-middleware
# OR
uv add lambda-middleware

Configuration

Set the Lambda function name via environment variable:

export LAMBDA_FUNCTION_NAME=your-lambda-function

Or create a .env file:

LAMBDA_FUNCTION_NAME=your-lambda-function

Usage

Programmatic Usage

import asyncio
from lambda_middleware import LambdaMiddleware

# Initialize with environment config
middleware = LambdaMiddleware()

# Or provide custom config
from lambda_middleware.config import Config
config = Config(lambda_function_name="my-function")
middleware = LambdaMiddleware(config=config)

# Call the Lambda function
async def main():
    response = await middleware.call_lambda({
        "action": "your_action",
        "params": {}
    })
    print(response)

asyncio.run(main())

CLI Usage

Check AWS credentials:

lambda-middleware middleware caller-identity

Call the Lambda function:

lambda-middleware middleware call --function-name my-lambda-function --message "test payload"

Dry Run Mode

Test IAM permissions without invoking the function:

response = await middleware.call_lambda(
    {"action": "your_action"},
    dry_run=True
)

Requirements

  • Python 3.13+
  • AWS credentials configured (via ~/.aws/credentials, environment variables, or IAM role)
  • Access to the target Lambda function

Development

Install development dependencies:

uv add --dev pytest pytest-mock pytest-asyncio

Run tests:

pytest

License

Internal use only - Factored organization.

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

lambda_middleware-0.3.0.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

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

lambda_middleware-0.3.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file lambda_middleware-0.3.0.tar.gz.

File metadata

  • Download URL: lambda_middleware-0.3.0.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.22

File hashes

Hashes for lambda_middleware-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3c7fdcbdbe7fe0856bd48a1fccad60f5db039ad52b1a21554d1b632d84504283
MD5 03043e24dab349fc7ae5871a83f4268a
BLAKE2b-256 ac7749df8e887c523179b32e8e88d92272fd265bb48b5d478638c40bec773efa

See more details on using hashes here.

File details

Details for the file lambda_middleware-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lambda_middleware-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd9a143a3f5f0076ff869bd2b19bc788b6379b1a1bc9c43b6d45783ed3674d9d
MD5 3c7f37e2d8c8a75201252bff73932076
BLAKE2b-256 5dcb3b438f5d0881e18e0fa4f6592c4a01e247fe51f5b4be8b9325d1209fa04f

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