Skip to main content

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.

Metadata

Release files for aws-lwa-readiness-check 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-lwa-readiness-check 0.1.0
File Size Uploaded
aws-lwa-readiness-check-0.1.0.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-lwa-readiness-check 0.1.0
File Interpreter ABI Platform
aws_lwa_readiness_check-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / aws-lwa-readiness-check-0.1.0.tar.gz

Download URL aws-lwa-readiness-check-0.1.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d2d6ed7623a9fb69ab7690e6a3b46a5fec13cab55e3a4473561424369f3cb0c4
BLAKE2b-256 checksum
How to use checksums
0de98d5dc83618cee1ed10ec89aa1f35ce74070abc6775ea4aaeefdb427719a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release files / aws_lwa_readiness_check-0.1.0-py3-none-any.whl

Download URL aws_lwa_readiness_check-0.1.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d412eb31b3b26892ded658ff64ecfd164de1ce86301954a51cd38482b4f8e59a
BLAKE2b-256 checksum
How to use checksums
5eddfd21b2a2f0d5d3a1b77723a27c1238d2ddd322478a11c677c976148101b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page