serverless-haskell: Deploying Haskell code onto AWS Lambda using Serverless

[ aws, cloud, library, mit, network ] [ Propose Tags ]

Utilities to help process the events from AWS Lambda when deployed with the serverless-haskell plugin.


[Skip to Readme]
Versions 0.0.0, 0.0.2, 0.0.3, 0.0.4, 0.0.6, 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0
Dependencies aeson, aeson-casing, aeson-extra, amazonka-core, amazonka-kinesis, amazonka-s3, base (>=4.7 && <5), bytestring, case-insensitive, http-types, iproute, lens, text, time, unix, unordered-containers [details]
License MIT
Author
Maintainer akotlyarov@seek.com.au
Category AWS, Cloud, Network
Home page https://github.com/seek-oss/serverless-haskell#readme
Bug tracker https://github.com/seek-oss/serverless-haskell/issues
Source repo head: git clone https://github.com/seek-oss/serverless-haskell
Uploaded by AlexeyKotlyarov at Thu May 24 03:04:42 UTC 2018
Distributions NixOS:0.4.3
Downloads 673 total (48 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2018-05-24 [all 3 reports]
Hackage Matrix CI

Modules

  • AWSLambda
    • AWSLambda.Events
      • AWSLambda.Events.APIGateway
      • AWSLambda.Events.KinesisEvent
      • AWSLambda.Events.Records
      • AWSLambda.Events.S3Event
      • AWSLambda.Events.SNSEvent
    • AWSLambda.Handler
    • AWSLambda.Orphans
  • Data
    • Aeson
      • Data.Aeson.Alternative
      • Data.Aeson.Embedded
      • Data.Aeson.TextValue

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for serverless-haskell-0.5.0

[back to package description]

Serverless Haskell

Build status Hackage Hackage dependencies npm

Deploying Haskell code onto AWS Lambda using Serverless.

Requirements

Usage

  • Create a Stack package for your code:

    stack new mypackage
    

    LTS 9 and 10 are supported, older versions are likely to work too but untested.

  • Initialise a Serverless project inside the Stack package directory and install the serverless-haskell plugin:

    cd mypackage
    npm init .
    npm install --save serverless serverless-haskell
    
  • Create serverless.yml with the following contents:

    service: myservice
    
    provider:
      name: aws
      runtime: nodejs8.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. The handler field may be prefixed
        # with a path of the form `dir1/.../dirn`, relative to `serverless.yml`,
        # which points to the location where the Haskell package `mypackage` is
        # defined. This prefix is not needed when the Stack project is defined at
        # the same level as `serverless.yml`.
    
    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 yet.

    The serverless-haskell plugin will build the package using Stack and upload it to AWS together with a JavaScript wrapper to pass the input and output from/to AWS Lambda.

    You can test the function and see the invocation results with sls invoke myfunc.

Notes

  • sls deploy function is not supported yet.
  • sls invoke local is not supported yet.
  • Only AWS Lambda is supported at the moment. Other cloud providers would require different JavaScript wrappers to be implemented.

See AWSLambda for documentation, including additional options to control the deployment.

Testing

  • Haskell code is tested with Stack: stack test.
  • JavaScript code is linted with eslint.

Integration tests

Integration test verifies that the project can build and deploy a complete function to AWS, and it runs with expected functionality.

Integration test is only automatically run up to deployment due to the need for an AWS account. To run manually:

  • Ensure you have the required dependencies: curl, jq, NPM, pwgen and Stack.
  • Get an AWS account and add the access credentials into your shell environment.
  • Run ./integration-test/run.sh. The exit code indicates success.
  • To verify just the packaging, without deployment, run ./integration-test/run.sh --dry-run.

Releasing

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