packages feed

serverless-haskell 0.1.0 → 0.2.0

raw patch · 3 files changed

+86/−24 lines, 3 files

Files

README.md view
@@ -2,17 +2,34 @@  Deploying Haskell code onto [AWS Lambda] using [Serverless]. +## Requirements++* AWS account+* [`stack`](Stack)+* [NPM]+* [Docker] unless running on a Linux host+ ## Usage -* Initialise a Serverless project in the same directory as your Stack-enabled-  package.+* Create a [Stack] package for your code: -* 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`).+  ```shell+  stack new mypackage+  ``` -* Add the following to `serverless.yml`:+  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:++  ```shell+  cd mypackage+  npm init .+  npm install --save serverless serverless-haskell+  ```++* Create `serverless.yml` with the following contents:+   ```yaml   provider:     name: aws@@ -47,9 +64,22 @@ * Use `sls deploy` to deploy the executable to AWS Lambda. **Note**: `sls deploy   function` is not supported. +  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.+* Only AWS Lambda is supported at the moment. Other cloud providers would+  require different JavaScript wrappers to be implemented.+ See [AWSLambda](https://hackage.haskell.org/package/serverless-haskell/docs/AWSLambda.html)-for the documentation.+for documentation, including additional options to control the deployment.  ## Releasing @@ -58,4 +88,7 @@ * Run `git push --tags && git push`.  [AWS Lambda]: https://aws.amazon.com/lambda/+[Docker]: https://www.docker.com/+[NPM]: https://www.npmjs.com/ [Serverless]: https://serverless.com/framework/+[Stack]: https://haskellstack.org
serverless-haskell.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 9f8f42c39c47eb860db76ff109b447b37326ae914e1e88eaccbcb7f6734e00e8+-- hash: 71347bf6b2f435283ac10c52af2a1e535e06447a7f62ef695bbc6e958a8732f0  name:           serverless-haskell-version:        0.1.0+version:        0.2.0 synopsis:       Deploying Haskell code onto AWS Lambda using Serverless description:    Utilities to help process the events from AWS Lambda when deployed with the serverless-haskell plugin. category:       AWS, Cloud, Network
src/AWSLambda.hs view
@@ -3,20 +3,19 @@ Stability   : experimental Portability : POSIX -Tools for running Haskell on AWS Lambda.+Tools for running Haskell on AWS Lambda using Serverless.  = Usage  To deploy a Haskell function on AWS Lambda:  * Initialise a Serverless project in the same directory as your Stack-enabled-  package.+  package and install the @serverless-haskell@ plugin: -* 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@).+  > npm init .+  > npm install --save serverless serverless-haskell -* Add the following to @serverless.yml@:+* Create @serverless.yml@ with the following contents:    > provider:   >   name: aws@@ -24,9 +23,9 @@   >   > functions:   >   myfunc:-  >     handler: mypackage.myfunc-  >     # Here, mypackage is the Haskell package name and myfunc is the executable-  >     # name as defined in the Cabal file+  >     handler: mypackage.mypackage-exe+  >     # Here, mypackage is the Haskell package name and mypackage-exe is the+  >     # executable name as defined in the Cabal file   >   > plugins:   >   - serverless-haskell@@ -36,15 +35,45 @@ * Use @sls deploy@ to deploy the executable to AWS Lambda. __Note__: @sls deploy   function@ is not supported. +  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`.+ = Additional features -To add flags to @stack build@, add the following key to @serverless.yml@:+Configuration options are passed to the plugin under @haskell@ key in @custom@+section of @serverless.yml@. -> custom:->   haskell:->     stackBuildArgs:->       - --pedantic->       - --allow-different-user+* To add flags to @stack build@, specify them as an array under+  @stackBuildArgs@:++  > custom:+  >   haskell:+  >     stackBuildArgs:+  >       - --pedantic+  >       - --allow-different-user++* To start the executable with extra arguments, add them to @arguments@ under+  the function name:++  > custom:+  >   haskell:+  >     arguments:+  >       myfunc:+  >         - --arg1+  >         - --arg2+  >         - arg3++* To include dependent libraries, list them under @extraLibraries@. The+  libraries will be uploaded to AWS Lambda along with the executable.++  > custom:+  >   haskell:+  >     extraLibraries:+  >       - libpcre.so.3 -} module AWSLambda   ( Handler.lambdaMain