ASGI middleware for handling readiness check requests from AWS Lambda Web Adapter
Project description
Readiness Check for AWS Lambda Web Adapter
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
Release history Release notifications | RSS feed
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
File details
Details for the file aws-lwa-readiness-check-0.1.0.tar.gz
.
File metadata
- Download URL: aws-lwa-readiness-check-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2d6ed7623a9fb69ab7690e6a3b46a5fec13cab55e3a4473561424369f3cb0c4 |
|
MD5 | bf7399a1f5df3f5a087518f9ae98d0f1 |
|
BLAKE2b-256 | 0de98d5dc83618cee1ed10ec89aa1f35ce74070abc6775ea4aaeefdb427719a0 |
File details
Details for the file aws_lwa_readiness_check-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: aws_lwa_readiness_check-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d412eb31b3b26892ded658ff64ecfd164de1ce86301954a51cd38482b4f8e59a |
|
MD5 | b40522cbd64ede6ca6583862c4aa7f23 |
|
BLAKE2b-256 | 5eddfd21b2a2f0d5d3a1b77723a27c1238d2ddd322478a11c677c976148101b1 |