Integrate your python applications with AWS Lambda and https://pythondeploy.co/.
Project description
Handle AWS Lambda events.
Events are passed to handlers for processing. Each event is passed to the handler in this order:
Handler defined in the event
HTTP events handler (for WSGI applications)
SQS events handler (if configured)
Default handler (if configured)
Logger handler (if no default is defined)
Provided Handlers
pd_aws_lambda.handlers.wsgi.handler: convert HttpAPI requests to WSGI environs.
pd_aws_lambda.handlers.shell.handler: Run shell commands.
pd_aws_lambda.handlers.logger.handler: log the received event and context.
Usage
Add pd-aws-lambda to your application dependencies.
poetry add pd-aws-lambda
Set the required environment variables according to your needs in your Python Deploy application configuration.
# Python path to the WSGI application that will handle HTTP requests. PD_WSGI_APPLICATION=
my_django_project.wsgi.application# Python path to the handler for SQS events. PD_SQS_HANDLER=my_custom_handlers.sqs_handler# Python path to the default fallback handler. PD_DEFAULT_HANDLER=my_custom_handlers.default_handler
Custom handlers
A handler is a python function that receives an event and a context and does something with them. It can return a value if it makes sense for the type of event. For example, HttpAPI handlers like the one we use to call your wsgi application (pd_aws_lambda.handlers.wsgi.handler) should return a dictionary compatible with the AWS HttpAPI to form an HTTP response.
def handler(event, context):
"""
I handle AWS Lambda invocations.
I print the received event and context.
"""
print("The event:", event)
print("The context:", context)
Developed to be used with Python Deploy.
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
Built Distribution
Hashes for pd_aws_lambda-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42667b6cdc000e17afb2bfab8ee8b37e1cd63ec247f0d84c2d5b85095570edc4 |
|
MD5 | 89f0eee388cce70c294c6e81884d9391 |
|
BLAKE2b-256 | 91a4d9614459456b823ccaa933672caf0e1498b02a81ada831fd9e46ec3fb3ff |