serverless-haskell

Deploying Haskell code onto AWS Lambda using Serverless

https://github.com/seek-oss/serverless-haskell#readme

Version on this page:0.1.0
LTS Haskell 18.28:0.12.6
Stackage Nightly 2021-06-14:0.12.6
Latest on Hackage:0.12.6

See all snapshots serverless-haskell appears in

MIT licensed
Maintained by [email protected]
This version can be pinned in stack with:serverless-haskell-0.1.0@sha256:59cc9e7df164c76dc5170d3fa8609f3ddbaf4358ea4e8b4601ce2a5b6dfacbcd,2148

Serverless Haskell

Deploying Haskell code onto AWS Lambda using Serverless.

Usage

  • Initialise a Serverless project in the same directory as your Stack-enabled package.

  • Install serverless-haskell plugin (Warning: not uploaded to NPM registry yet, install manually by cloning this repository and specifying its serverless-plugin directory to npm install).

  • Add the following to serverless.yml:

    provider:
      name: aws
      runtime: nodejs6.10
    
    functions:
      myfunc:
        handler: mypackage.myfunc
        # Here, mypackage is the Haskell package name and myfunc is the executable
        # name as defined in the Cabal file
    
    plugins:
      - serverless-haskell
    
  • Write your main function:

    import qualified Data.Aeson as Aeson
    
    import AWSLambda
    
    main = lambdaMain handler
    
    handler :: Aeson.Value -> IO [Int]
    handler evt = do
      putStrLn "This should go to logs"
      print evt
      pure [1, 2, 3]
    
  • Use sls deploy to deploy the executable to AWS Lambda. Note: sls deploy function is not supported.

See AWSLambda for the documentation.

Releasing

  • Install bumpversion: pip install bumpversion.
  • Run bumpversion major|minor|patch.
  • Run git push --tags && git push.