serverless-haskell 0.12.1 → 0.12.2
raw patch · 3 files changed
+65/−22 lines, 3 files
Files
- README.md +43/−17
- serverless-haskell.cabal +2/−2
- src/AWSLambda.hs +20/−3
README.md view
@@ -30,18 +30,18 @@ ``` * 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 @@ 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 @@ 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 @@ 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: - To invoke the function locally, use `sls invoke local -f myfunc`.+ ```+ sls invoke -f myfunc`+ ```+ ### API Gateway
serverless-haskell.cabal view
@@ -4,10 +4,10 @@ -- -- 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
src/AWSLambda.hs view
@@ -12,7 +12,7 @@ * 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,16 +37,33 @@ * 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