Skip to main content

This package provides a decorator for Python Lambda functions handling AWS Lambda Event Records.

Project description

AWS Lambda Event Handler

This package provides a decorator for Python Lambda functions handling individual records in the event payload of the AWS Lambda function.

Usage

This package provides two event decorators:

  • sns - used to handle invokations that origin from a SNS Topic.
  • dynamodb - used to handle invokations that origin from a DynamoDB Stream.

Defining the Handler

The following demonstrates how to create a handler object that will be used as the entrypoint for various event sources that trigger a AWS Lambda invokation:

from lambda_handler import LambdaHandler
handler = LambdaHandler() #pylint: disable=C0103

The handler object can then be used as a decorator for various Lambda Event Sources:

from lambda_handler import SNSMessage

@handler.sns
def sns(message: SNSMessage, context) -> None:
    """
    Handle SNS Message
    """
    print(message)

@handler.dynamodb
def dynamodb(record: dict, context) -> None:
    """
    Handle DynamoDB record
    """
    print(record)

Models

SNSMessage

The SNSMessage model makes it easier to interact with the data in the records and does some of the heavy lifting of pulling payload and attributes from the event letting you focus on your business logic.

Installation

pip install aws-lambda-event-handler

Requirements

None

Authors

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

aws_lambda_event_handler-0.0.3.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

aws_lambda_event_handler-0.0.3-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

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