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.1.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.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lambda_middleware-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d96a1fbf26207f151931e3394b7b0e5a4b988345ac23e07d9bd5fec4ad07c2b8
MD5 94638e075ba0547394529d9adb4c1419
BLAKE2b-256 4a60fd651b8d0afd506a8722c646c22a664b2014b97bb512dbeb56adeaa14879

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lambda_middleware-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b151eb3265f619b1b35c06da0a24f4a87fca4d82369c0a57e7d60b3842a086c1
MD5 4c70861dce9f888f4f72a51f6d4500ad
BLAKE2b-256 fc09d5ec228e92160a5b1f89c683c9754fb1f18d8564502824731d800fce34ae

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