Code Monkey home page Code Monkey logo

alb_response's Introduction

License Code Style

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

  1. Setup an Application Load Balancer (ALB)
  2. Create a target group for the Lambda
  3. Assign appropriate permissions to your Lambda function
  4. 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
  • 0.1.2
    • Patch to support null json responses without sending an empty json object

alb_response's People

Contributors

djfurman avatar karthikkalasani avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

karthikkalasani

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.