Skip to main content

ASGI middleware for handling readiness check requests from AWS Lambda Web Adapter

Project description

Readiness Check for AWS Lambda Web Adapter

Python 3.10+ License: MIT

A lightweight ASGI middleware for handling readiness check requests from AWS Lambda Web Adapter (LWA).

The AWS Lambda Web Adapter allows you to run web applications on AWS Lambda by handling the translation between HTTP APIs and Lambda events.

Purpose

This middleware helps prevent the Resource did not stabilize error during Lambda deployment by responding to the LWA readiness check request before your application completes its initialization. Without proper handling of these requests, the Lambda runtime may fail to start properly.

Installation

pip install aws-lwa-readiness-check

Usage

from lwa_readiness.asgi import ReadinessCheckMiddleware

# Wrap your ASGI application
app = ReadinessCheckMiddleware(your_asgi_app)

Configuration

The middleware requires the following environment variable:

  • AWS_LWA_READINESS_CHECK_PATH: The URL path for readiness check requests

⚠️ Important: The default value is /, which may conflict with your application's routes. It's recommended to change it to a unique path that your application doesn't use, for example /lwa-readiness-check.

How It Works

The middleware intercepts HTTP requests to the configured path and returns an immediate HTTP 200 response without forwarding the request to your application. All other requests are passed through to your application unchanged.

Example

Django

import os
from django.core.asgi import get_asgi_application
from lwa_readiness.asgi import ReadinessCheckMiddleware

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'path.to.django.settings')

application = ReadinessCheckMiddleware(
    get_asgi_application()
)

FastAPI

from fastapi import FastAPI
from lwa_readiness.asgi import ReadinessCheckMiddleware

app = FastAPI()

app.add_middleware(ReadinessCheckMiddleware)

License

This project is licensed under the MIT License. See the LICENSE file for details.

Disclaimer

This software product is not affiliated with, endorsed by, or sponsored by Amazon Web Services (AWS) or Amazon.com, Inc. The use of the term "AWS" is solely for descriptive purposes to indicate that the software is compatible with AWS services. Amazon Web Services and AWS are trademarks of Amazon.com, Inc. or its affiliates.

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-lwa-readiness-check-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

aws_lwa_readiness_check-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file aws-lwa-readiness-check-0.1.0.tar.gz.

File metadata

File hashes

Hashes for aws-lwa-readiness-check-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d2d6ed7623a9fb69ab7690e6a3b46a5fec13cab55e3a4473561424369f3cb0c4
MD5 bf7399a1f5df3f5a087518f9ae98d0f1
BLAKE2b-256 0de98d5dc83618cee1ed10ec89aa1f35ce74070abc6775ea4aaeefdb427719a0

See more details on using hashes here.

File details

Details for the file aws_lwa_readiness_check-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_lwa_readiness_check-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d412eb31b3b26892ded658ff64ecfd164de1ce86301954a51cd38482b4f8e59a
MD5 b40522cbd64ede6ca6583862c4aa7f23
BLAKE2b-256 5eddfd21b2a2f0d5d3a1b77723a27c1238d2ddd322478a11c677c976148101b1

See more details on using hashes here.

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