aws-lwa-readiness-check


Nameaws-lwa-readiness-check JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/efficient-solutions/aws-lwa-readiness-check
SummaryASGI middleware for handling readiness check requests from AWS Lambda Web Adapter
upload_time2024-11-01 23:36:07
maintainerNone
docs_urlNone
authorEfficient Solutions LLC
requires_python>=3.10
licenseMIT
keywords aws lambda aws lambda web adapter asgi
VCS
bugtrack_url
requirements twine
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Readiness Check for AWS Lambda Web Adapter

[![Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/efficient-solutions/aws-lwa-readiness-check/blob/main/LICENSE)

A lightweight ASGI middleware for handling readiness check requests from [AWS Lambda Web Adapter](https://github.com/awslabs/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

```bash
pip install aws-lwa-readiness-check
```

## Usage

```python
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

```python
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

```python
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](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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/efficient-solutions/aws-lwa-readiness-check",
    "name": "aws-lwa-readiness-check",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "AWS Lambda, AWS Lambda Web Adapter, ASGI",
    "author": "Efficient Solutions LLC",
    "author_email": "contact@efficient.solutions",
    "download_url": "https://files.pythonhosted.org/packages/0d/e9/8d5dc83618cee1ed10ec89aa1f35ce74070abc6775ea4aaeefdb427719a0/aws-lwa-readiness-check-0.1.0.tar.gz",
    "platform": null,
    "description": "# Readiness Check for AWS Lambda Web Adapter\n\n[![Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/efficient-solutions/aws-lwa-readiness-check/blob/main/LICENSE)\n\nA lightweight ASGI middleware for handling readiness check requests from [AWS Lambda Web Adapter](https://github.com/awslabs/aws-lambda-web-adapter) (LWA). \n\nThe AWS Lambda Web Adapter allows you to run web applications on AWS Lambda by handling the translation between HTTP APIs and Lambda events.\n\n## Purpose\n\nThis 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.\n\n## Installation\n\n```bash\npip install aws-lwa-readiness-check\n```\n\n## Usage\n\n```python\nfrom lwa_readiness.asgi import ReadinessCheckMiddleware\n\n# Wrap your ASGI application\napp = ReadinessCheckMiddleware(your_asgi_app)\n```\n\n## Configuration\n\nThe middleware requires the following environment variable:\n\n- `AWS_LWA_READINESS_CHECK_PATH`: The URL path for readiness check requests\n\n\u26a0\ufe0f **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`.\n\n## How It Works\n\nThe 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.\n\n## Example\n\n### Django\n\n```python\nimport os\nfrom django.core.asgi import get_asgi_application\nfrom lwa_readiness.asgi import ReadinessCheckMiddleware\n\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'path.to.django.settings')\n\napplication = ReadinessCheckMiddleware(\n    get_asgi_application()\n)\n```\n\n### FastAPI\n\n```python\nfrom fastapi import FastAPI\nfrom lwa_readiness.asgi import ReadinessCheckMiddleware\n\napp = FastAPI()\n\napp.add_middleware(ReadinessCheckMiddleware)\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Disclaimer\n\nThis 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.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "ASGI middleware for handling readiness check requests from AWS Lambda Web Adapter",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/efficient-solutions/aws-lwa-readiness-check"
    },
    "split_keywords": [
        "aws lambda",
        " aws lambda web adapter",
        " asgi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5eddfd21b2a2f0d5d3a1b77723a27c1238d2ddd322478a11c677c976148101b1",
                "md5": "b40522cbd64ede6ca6583862c4aa7f23",
                "sha256": "d412eb31b3b26892ded658ff64ecfd164de1ce86301954a51cd38482b4f8e59a"
            },
            "downloads": -1,
            "filename": "aws_lwa_readiness_check-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b40522cbd64ede6ca6583862c4aa7f23",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 4702,
            "upload_time": "2024-11-01T23:36:05",
            "upload_time_iso_8601": "2024-11-01T23:36:05.917576Z",
            "url": "https://files.pythonhosted.org/packages/5e/dd/fd21b2a2f0d5d3a1b77723a27c1238d2ddd322478a11c677c976148101b1/aws_lwa_readiness_check-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0de98d5dc83618cee1ed10ec89aa1f35ce74070abc6775ea4aaeefdb427719a0",
                "md5": "bf7399a1f5df3f5a087518f9ae98d0f1",
                "sha256": "d2d6ed7623a9fb69ab7690e6a3b46a5fec13cab55e3a4473561424369f3cb0c4"
            },
            "downloads": -1,
            "filename": "aws-lwa-readiness-check-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bf7399a1f5df3f5a087518f9ae98d0f1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 4330,
            "upload_time": "2024-11-01T23:36:07",
            "upload_time_iso_8601": "2024-11-01T23:36:07.573064Z",
            "url": "https://files.pythonhosted.org/packages/0d/e9/8d5dc83618cee1ed10ec89aa1f35ce74070abc6775ea4aaeefdb427719a0/aws-lwa-readiness-check-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-01 23:36:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "efficient-solutions",
    "github_project": "aws-lwa-readiness-check",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "twine",
            "specs": [
                [
                    ">=",
                    "5.1"
                ],
                [
                    "<",
                    "5.2"
                ]
            ]
        }
    ],
    "lcname": "aws-lwa-readiness-check"
}
        
Elapsed time: 0.51016s