All Projects → seek-oss → Serverless Haskell

seek-oss / Serverless Haskell

Licence: mit
Deploying Haskell applications to AWS Lambda with Serverless

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Serverless Haskell

Aws Lambda Power Tuning
AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.
Stars: ✭ 3,040 (+1390.2%)
Mutual labels:  aws, serverless, aws-lambda
Dialetus Service
API to Informal dictionary for the idiomatic expressions that each Brazilian region It has
Stars: ✭ 202 (-0.98%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Sentry Plugin
This plugin adds automatic forwarding of errors and exceptions to Sentry (https://sentry.io) and Serverless (https://serverless.com)
Stars: ✭ 146 (-28.43%)
Mutual labels:  aws, serverless, aws-lambda
Components
The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
Stars: ✭ 2,259 (+1007.35%)
Mutual labels:  aws, serverless, aws-lambda
Serverlessish
Run the same Docker images in AWS Lambda and AWS ECS
Stars: ✭ 177 (-13.24%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Sam
Serverless framework plugin to export AWS SAM templates for a service
Stars: ✭ 143 (-29.9%)
Mutual labels:  aws, serverless, aws-lambda
Terraform Aws Lambda
Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations
Stars: ✭ 190 (-6.86%)
Mutual labels:  aws, serverless, aws-lambda
Spark On Lambda
Apache Spark on AWS Lambda
Stars: ✭ 137 (-32.84%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Aws Alias
Alias support for Serverless 1.x
Stars: ✭ 171 (-16.18%)
Mutual labels:  aws, serverless, aws-lambda
Cartoonify
Deploy and scale serverless machine learning app - in 4 steps.
Stars: ✭ 157 (-23.04%)
Mutual labels:  aws, serverless, aws-lambda
Rust Crowbar
Wrapper to simplify writing AWS Lambda functions in Rust (using the Python execution environment)
Stars: ✭ 198 (-2.94%)
Mutual labels:  aws, serverless, aws-lambda
Middy
🛵 The stylish Node.js middleware engine for AWS Lambda
Stars: ✭ 2,592 (+1170.59%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Pg
A package for managing PostgreSQL connections at SERVERLESS scale
Stars: ✭ 142 (-30.39%)
Mutual labels:  aws, serverless, aws-lambda
Selfie2anime
Anime2Selfie Backend Services - Lambda, Queue, API Gateway and traffic processing
Stars: ✭ 146 (-28.43%)
Mutual labels:  aws, serverless, aws-lambda
Shadowreader
Serverless load testing for replaying website traffic. Powered by AWS Lambda.
Stars: ✭ 138 (-32.35%)
Mutual labels:  aws, serverless, aws-lambda
Archive aws Lambda Go Net
Network I/O interface for AWS Lambda Go runtime.
Stars: ✭ 151 (-25.98%)
Mutual labels:  aws, serverless, aws-lambda
Aws Lambda List
A list of hopefully useful AWS lambdas and lambda-related resources.
Stars: ✭ 130 (-36.27%)
Mutual labels:  aws, serverless, aws-lambda
Cra Serverless
Serverless pre-rendering (SSR) for React SPA using AWS Lambda, S3, and CloudFront.
Stars: ✭ 137 (-32.84%)
Mutual labels:  aws, serverless, aws-lambda
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+1359.31%)
Mutual labels:  aws, serverless, aws-lambda
Chrome Aws Lambda
Chromium Binary for AWS Lambda and Google Cloud Functions
Stars: ✭ 2,502 (+1126.47%)
Mutual labels:  aws, serverless, aws-lambda

Serverless Haskell

Build status Hackage Stackage LTS Hackage dependencies npm

Deploying Haskell code onto AWS Lambda using Serverless.

Prerequisites

Usage

There are two ways to start, either via the stack template, or directly modifying a project. You may want to use the manual approach as the template specifies a specific stack resolver as it needs to hardcode the stack.yaml file.

In either case, you will want to have Serverless installed, eg. npm install -g serverless.

Using the stack template

  • Create a Stack package for your code:

    stack new mypackage https://raw.githubusercontent.com/seek-oss/serverless-haskell/master/serverless-haskell.hsfiles
    
  • Update the resolver in the stack.yaml file. This is hardcoded as the resolver number is not known at template interpolation time. You should pick either the latest resolver, or one you have used before and have thus prebuilt many of the core packages for.

  • Install the dependencies and build the project:

    cd mypackage
    npm install
    stack build
    sls invoke local -f mypackage-func
    

    This should invoke serverless locally and display output once everything has built.

Manually

  • Create a Stack package for your code:

    stack new mypackage
    

    LTS 9-16 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 -y
    npm install --save serverless [email protected]
    

    The version of the NPM package to install must match the version of the Haskell package.

  • Create serverless.yml with the following contents:

    service: myservice
    
    provider:
      name: aws
      runtime: haskell
    
    functions:
      myfunc:
        handler: mypackage.mypackage-exe
        # Here, mypackage is the Haskell package name and mypackage-exe 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]
    
  • Add aeson and serverless-haskell to package.yaml:

    dependencies:
    - base >= 4.7 && < 5
    - aeson
    - serverless-haskell
    
  • Build and test locally using sls invoke local:

    The serverless-haskell plugin will build the package using Stack. Note that the first build can take a long time. Consider adding export SLS_DEBUG=* so you can see what is happening.

    export SLS_DEBUG=*
    sls invoke local -f myfunc
    
  • Use sls deploy to deploy the executable to AWS Lambda.

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

    export SLS_DEBUG=*
    sls deploy
    

    You can test the function and see the invocation results with:

    sls invoke -f myfunc`
    

API Gateway

This plugin supports handling API Gateway requests. Declare the HTTP events normally in serverless.yml and use AWSLambda.Events.APIGateway in the handler to process them.

Serverless Offline can be used for local testing of API Gateway requests. You must use --useDocker flag so that the native Haskell runtime works correctly.

When using Serverless Offline, make sure that the project directory is world-readable, otherwise the started Docker container will be unable to access the handlers and all invocations will return HTTP status 502.

Notes

  • 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.

Development

master branch is the stable version. It is normally released to Hackage once new changes are merged via Git tags.

The package is also maintained in Stackage LTS, provided the dependencies are not blocking it.

Testing

  • Haskell code is tested with Stack: stack test.
  • TypeScript 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:
  • 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.
  • By default, the integration test is run with the LTS specified in stack.yaml. To specify a different series, use RESOLVER_SERIES=lts-9.
  • To avoid creating a temporary directory for every run, specify --no-clean-dir. This can speed up repeated test runs, but does not guarantee the same results as a clean test.

Releasing

  • Ensure you are on the master branch.
  • Ensure that all the changes are reflected in the changelog.
  • Run the integration tests.
  • Run ./bumpversion major|minor|patch. This will increment the version number, update the changelog, create and push the Git tag and the branch.
  • If you have released an LTS version, merge the version branch into master, taking care of the conflicts around version numbers and changelog, and release the latest version as well.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].