summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexeyKotlyarov <>2020-09-15 23:19:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-09-15 23:19:00 (GMT)
commit36f6dcf66dadd8d296cd237e491d47138b6bb09a (patch)
treea3c254ef19e0cf7ac7c65ee6840ecd1d501ee393
parentcfd3525ea6593dc45ef9b44ee9ac0b6e3b242378 (diff)
version 0.12.2HEAD0.12.2master
-rw-r--r--README.md60
-rw-r--r--serverless-haskell.cabal4
-rw-r--r--src/AWSLambda.hs23
3 files changed, 65 insertions, 22 deletions
diff --git a/README.md b/README.md
index 947e4bc..021e95a 100644
--- a/README.md
+++ b/README.md
@@ -30,18 +30,18 @@ In either case, you will want to have [Serverless] installed, eg. `npm install -
```
* 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:
-
+
```shell
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:
@@ -50,14 +50,14 @@ In either case, you will want to have [Serverless] installed, eg. `npm install -
stack new mypackage
```
- LTS 9-15 are supported, older versions are likely to work too but untested.
+ 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:
```shell
cd mypackage
- npm init .
+ npm init -y
npm install --save serverless serverless-haskell@x.y.z
```
@@ -75,13 +75,13 @@ In either case, you will want to have [Serverless] installed, eg. `npm install -
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`.
+ 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
@@ -103,16 +103,42 @@ In either case, you will want to have [Serverless] installed, eg. `npm install -
pure [1, 2, 3]
```
+* Add `aeson` and `serverless-haskell` to `package.yaml`:
+
+ ```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 and upload
+ 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.
- You can test the function and see the invocation results with
- `sls invoke -f myfunc`.
+ ```
+ export SLS_DEBUG=*
+ sls deploy
+ ```
+ You can test the function and see the invocation results with:
+
+ ```
+ sls invoke -f myfunc`
+ ```
- To invoke the function locally, use `sls invoke local -f myfunc`.
### API Gateway
diff --git a/serverless-haskell.cabal b/serverless-haskell.cabal
index a0dbe6a..00557a4 100644
--- a/serverless-haskell.cabal
+++ b/serverless-haskell.cabal
@@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
--- hash: 40b2acd2d0bc1eddea721bde88ddc17eb101d926cc891b5dcddd6083254be037
+-- hash: eb3183c0aeb30569bc69a5ef32f4f467d305108dd464c3f86d33b56507b3af46
name: serverless-haskell
-version: 0.12.1
+version: 0.12.2
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
diff --git a/src/AWSLambda.hs b/src/AWSLambda.hs
index ba2613a..f555075 100644
--- a/src/AWSLambda.hs
+++ b/src/AWSLambda.hs
@@ -12,7 +12,7 @@ To deploy a Haskell function on AWS Lambda:
* Initialise a Serverless project in the same directory as your Stack-enabled
package and install the @serverless-haskell@ plugin:
- > npm init .
+ > npm init -y
> npm install --save serverless serverless-haskell@x.y.z
The version of the NPM package to install must match the version of the
@@ -37,17 +37,34 @@ package and install the @serverless-haskell@ plugin:
* Write your @main@ function using 'AWSLambda.lambdaMain'.
+* 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 and 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@.
- To invoke the function locally, use @sls invoke local -f myfunc@.
-
= API Gateway
This plugin supports handling API Gateway requests. Declare the HTTP events