AWS ALB Response Creator
The AWS announcement of Application Load Balancers supporting Lambda functions made my reInvent experience!
Purpose
In doing a PoC however, I found that the statusDescription element was somewhat of an annoyance to code. This package provides a method to return the appropriate format of this field without copy/paste response data and allowing a strategy to implement this to swap out response formats for API Gateway or ALB as needed.
Installation
Run pip install alb-response
Usage
from alb_response import alb_response
def lambda_handler(event, context):
response_dict = process_the_event(event)
return alb_response(
http_status=200,
json=response_dict,
is_base64_encoded=False,
)
Architecture
- Setup an Application Load Balancer (ALB)
- Create a target group for the Lambda
- Assign appropriate permissions to your Lambda function
- Attach the target group to the ALB with a rule
Contributing
Contributions are welcome! Please open an issue or make a pull request.
If making a pull request, please run the tests and ensure that you maintain or increase code coverage.
Dependencies
To make this project more portable and keep environments organized, this project leverages pipenv. To install deterministic dependencies, run pipenv sync.
Run Tests
To run the tests, install the dependencies and run behave.
To get code coverage as well, run coverage run --source='.' -m behave followed by coverage report.
Release Log
0.1.0- Initial Release
0.1.1- Dependency update to resolve CVE-2019-11324.
0.1.2- Patch to support null json responses without sending an empty json object
Metadata
Release files for alb-response 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| alb-response-0.1.2.tar.gz | 2.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alb_response-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / alb-response-0.1.2.tar.gz
| Download URL | alb-response-0.1.2.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1f1d32e9145b252eb85ed4fd6b261b40bc39a67b687c380dc08e86ae022d9ca
|
|
BLAKE2b-256 checksum How to use checksums |
00c0e31ecc4f33c50a61e69e9e19696b2f68457c4356a365894eb690d0c2db9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
|
Release files / alb_response-0.1.2-py3-none-any.whl
| Download URL | alb_response-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b13610e1daad50e2cc8477801a7ad8e72f4418de9022604384ee02c2c72e9079
|
|
BLAKE2b-256 checksum How to use checksums |
9555cdb4bb62a67967f936b1de4de559764311379a84dcb5b89075b33b124565
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
|