wai-lambda: Haskell Webapps on AWS Lambda

[ library, mit, program, web ] [ Propose Tags ]

Turn any wai webapp ( spock, servant, etc) into a handler for AWS Lambda and API Gateway requests.

Works with any Lambda environment (nodejs, python, etc). Find out more in the README.

[Skip to Readme]
Versions [faq]
Dependencies aeson, base (<5), binary, bytestring, case-insensitive, directory, http-types, iproute, network, temporary, text, unliftio, unordered-containers, vault, wai, wai-lambda [details]
License MIT
Copyright (c) 2019 David Dal Busco and Nicolas Mattia
Author Nicolas Mattia <nicolas@nmattia.com>
Maintainer Nicolas Mattia <nicolas@nmattia.com>
Category Web
Home page https://github.com/deckgo/wai-lambda#readme
Bug tracker https://github.com/deckgo/wai-lambda/issues
Source repo head: git clone https://github.com/deckgo/wai-lambda
Uploaded by nmattia at Wed Mar 20 13:18:49 UTC 2019
Distributions NixOS:
Executables wai-lambda
Downloads 42 total (14 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-03-20 [all 1 reports]


[Index] [Quick Jump]


Maintainer's Corner

For package maintainers and hackage trustees

Readme for wai-lambda-

[back to package description]
<p align="center"> <img src="assets/wai-lambda.png" alt="wai-lambda" width="200"/> </p>

WAI Lambda - Haskell Webapps on AWS Lambda


This Haskell library turns any wai webapp (spock, servant, etc) into a handler for AWS Lambda and API Gateway requests.

{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.HTTP.Types
import Network.Wai.Handler.Lambda (run)

app :: Application
app _ respond = do
    putStrLn "I've done some IO here"
    respond $ responseLBS
        [("Content-Type", "text/plain")]
        "Hello, Web!"

main :: IO ()
main = run app

This doesn't require any particular Lambda environment. By following the instructions in the build section the resulting zip file uploaded to AWS Lambda is typically be smaller than 1MB. For basic webapps the request handling duration (as reported by AWS) is between 1 and 5 milliseconds.



Installing with Cabal:

$ cabal install wai-lambda


If you use stack and wai-lambda is not included in your snapshot, add it to the extra-deps:

  - wai-lambda-

or from GitHub:

- ...
- location:
    git: https://github.com/deckgo/wai-lambda.git
    commit: <some commit>
  extra-dep: true


You do not have to do anything if you use cabal2nix and a Nix commit that includes wai-lambda in its Hackage dependencies. If you want to use a specific commit of wai-lambda we recommend using niv:

$ niv add deckgo/wai-lambda

Then add an override to your Nix packages:

    sources = import ./nix/sources.nix; # from niv
    pkgs = import sources.nixpkgs {};

    myHaskellPackages = pkgs.haskellPackages.override
        { overrides = self: super:
            { "wai-lambda" =
                super.callCabal2nix "wai-lambda" sources.wai-lambda;

See also the build section for producing AWS Lambda packages with nix.



For inspiration on how to build fully static executables with Nix, see DeckDeckGo



For inspiration on how to deploy with Terraform and Nix, see DeckDeckGo


MIT © David Dal Busco and Nicolas Mattia