Coder Social home page Coder Social logo

aws-lambda-oauth-extension's Introduction

aws-lambda-oauth-extension

Build and Test

caching and oauth client credentials layer for lambda

  1. the extension will start a http server in init phase at port 8081
  2. in invoke phase, function can send request to localhost:8081 with header Host: example.com, the request will automatically authenticated then proxy to example.com
  3. extension turns off the server when receiving shutdown event

👾Install

example: add extension to a Python image

FROM public.ecr.aws/lambda/python:3.8

# Copy and install the app
COPY /app /app
WORKDIR /app
RUN pip install -r requirements.txt

# extract the extension into root folder
ADD extension.tar.gz /
CMD python ./index.py

⚙️ Config

config can be add as file or inline through environment variables ALOE_CONFIG

File

  1. Add config file to image
...
# app config into image
ADD config.dhall /opt/extensions/
# extract the extension into root folder
ADD extension.tar.gz /
...
  1. add env to lambda ALOE_CONFIG=/opt/extensions/config.dhall

Inline Dhall

in template.dhall

Environment = Some Funtion.Environment::{
  Variables = Some (toMap {
    ALOE_CONFIG = ./config.dhall as Text
  })
}

🦄 Contribute

Prerequisites

  1. nix for macOS or Linux
curl https://nixos.org/nix/install | sh
  1. stack
nix-env -i stack

Build

stack build

Package

binary

nix-build

binary will be generated in ./result/bin/aws-lambda-oauth-extension-exe

docker

  • on Linux
docker load < $(nix-build docker.nix)

docker image is tagged ghcr.io/myob-technology/aws-lambda-oauth-extension:latest

  • on macOS
docker-compose run --rm build-image
docker load < image.gz

Test

nix-shell --run 'bats test'

Ref

aws-lambda-oauth-extension's People

Contributors

jcouyang avatar

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.