Skip to main content

A collection of useful decorators for making AWS Lambda handlers

Project description

A collection of useful decorators for making AWS Lambda handlers

NOTE: this is in very early stages of development.

lambda_decorators is a collection of useful decorators for writing Python handlers for AWS Lambda. They allow you to avoid boiler plate for common things such as CORS headers, JSON serialization, etc.

These can be used as a library or simply copied and adapted to your needs. If you want to write your own “middlewares” it’s as easy as writing a decorator. The documentation has links to the source of each decorator. They also serve as handy examples for implemenenting your own boilerplate-reducing decorators.

Quick example


from lambda_decorators import cors_headers, json_http_resp, load_json_body

def handler(event, context):
    return {'hello': event['body']['name']}

When deployed to Lambda behind API Gateway and cURL’d:

$ curl -d '{"name": "world"}'
{"hello": "world"}


pip install lambda-decorators


Initially, I was inspired by middy which I’ve tried out in JavaScript and was happy with it. So naturally, I thought I’d like to have something similar in Python too. But then as I thought about it more, it seemed that when thinking of functions as the compute unit, when using python, decorators pretty much are middleware! So instead of building a middleware engine and a few middlewares, I just built a few useful decorators.

Included Decorators:

See each individual decorators for specific usage details and the example for some more use cases.

Full API Documentation

Project details

Download files

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

Files for lambda-decorators, version 0.1a4
Filename, size File type Python version Upload date Hashes
Filename, size lambda_decorators-0.1a4-py3-none-any.whl (7.3 kB) File type Wheel Python version 3.6 Upload date Hashes View hashes
Filename, size lambda-decorators-0.1a4.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page