Skip to main content

Python client for AWS Lambda middleware functions

Project description

Factored Databricks Middleware

A Python client library for calling AWS Lambda functions that serve as middleware to the Databricks API. This package simplifies the integration with your organization's Databricks infrastructure by providing a clean, typed interface for Lambda invocations.

Features

  • Simple API: Just instantiate DatabricksMiddleware and call methods
  • Flexible Configuration: Environment variables or programmatic configuration
  • CLI Interface: Test 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-databricks-middleware-function

Or create a .env file:

LAMBDA_FUNCTION_NAME=your-databricks-middleware-function

Usage

Programmatic Usage

import asyncio
from lambda_middleware import DatabricksMiddleware

# Initialize with environment config
middleware = DatabricksMiddleware()

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

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

asyncio.run(main())

CLI Usage

Check AWS credentials:

middleware caller-identity

Call the Lambda function:

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

Dry Run Mode

Test IAM permissions without invoking the function:

response = await middleware.call_lambda(
    {"action": "describe_cluster"},
    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.2.12.tar.gz (25.1 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.2.12-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lambda_middleware-0.2.12.tar.gz
Algorithm Hash digest
SHA256 4a52c6b658f319a0703a0aed9b44e9c40db78d9c9ff1066f3e42311e845286e9
MD5 c422daaf8b3333fec382986a73d552fc
BLAKE2b-256 8d0a6afc235ecb5181de633786e7ce9562a664e67d5264466f419f5aa4998f4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lambda_middleware-0.2.12-py3-none-any.whl
Algorithm Hash digest
SHA256 02c8d331d7a42ea685829811067812094c32c0cfcea3e618a702b8f8d6a348a8
MD5 29fec0f688fd2ea731b47a8ce831ebe1
BLAKE2b-256 c63706b63b1aa5ef5defe2c6317393a146a48438cfe415574f02d53f4e059756

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