benzene.aws

Host Benzene handlers on AWS Lambda — API Gateway (HTTP), SQS, and SNS event sources in one function — plus SNS/SQS outbound clients. Distribution: benzene-aws (depends on benzene-core, benzene-http).

pip install benzene-aws            # add [boto3] for the real outbound clients

Overview

One host, inner bindings selected by event shape (transport-bindings §1):

Topic for SQS/SNS comes from the topic message attribute.

AwsLambdaApp

from benzene.aws import AwsLambdaApp, to_lambda_handler

app = AwsLambdaApp(http_router=router, registry=registry)   # shares one pipeline across sources
handler = to_lambda_handler(app)                            # def handler(event, context)

Outbound clients

Both implement benzene.core.MessageSender, carry the Benzene topic in the topic message attribute, forward headers as attributes, and use boto3 (a lazy, optional import).

Testing

benzene.aws.testing provides AwsLambdaTestHost (send_http, send_sqs, send_sqs_event, send_sns) and ApiGatewayRequestBuilder / SqsEventBuilder / SnsEventBuilder. See Hosting on AWS Lambda and the runnable examples/aws_orders.

See also