Giter Club home page Giter Club logo

serverless-haskell's Introduction

Serverless Haskell

Build status Hackage Stackage LTS Hackage dependencies npm

Deploying Haskell code onto AWS Lambda as native runtime 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 10-17 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.

serverless-haskell's People

Contributors

colehaus avatar dependabot[bot] avatar dmoverton avatar jhrcek avatar khanage avatar koterpillar avatar seanhess avatar tehnix avatar tmortiboy avatar wuzzeb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-haskell's Issues

LTS 14: GLIBC_2.27 not found

Following from: #113
I have written a simple servant server and converted it into a lambda function that queries a MySQL postgres db in amazon RDS. I can get it to work locally with serverless offline start.

However when I deploy it (serverless deploy) I get the following error in my logs when trying to access my simple test endpoint: ./apigw: /lib64/libm.so.6: version GLIBC_2.27 not found (required by ./apigw)

Support binary dependencies

Binary dependencies should be listed in custom.haskell.binaryDependencies and packaged along with the executables. The library dependencies of each binary dependency would also be packaged.

I'm working on a fix which would put the binaries in a sub-directory. This sub-directory would be added to PATH, after which the executable would be executed. Do you think this is a good solution?

Support use in projects with non-Haskell functions

Currently, the plugin tries to build all functions as if they were Haskell, and fails if any of them aren't. There should be some way to identify the functions as Haskell so that it only builds them and ignores the others. This would allow it to be used in polyglot projects.

sls invoke local hangs forever + errors

Hey there, I'm excited to try this out! Following the README, I'm unable to get sls invoke local to do anything.

Behavior
$ sls invoke local -f mypackage-func

It just sits there. I've tried entering JSON as if it were a prompt and it does nothing.

Expected Behavior
I thought it would output the results of Main.handler

Steps to Reproduce

  1. $ stack new mypackage https://raw.githubusercontent.com/seek-oss/serverless-haskell/master/serverless-haskell.hsfiles
  2. Update resolver to lts-16.3
  3. $ npm install
  4. $ stack build
  5. $ sls invoke local -f mypackage-func

I then get the following error

Serverless: Package version mismatch: serverless-haskell installed from NPM: 0.8.11, installed from Stack: 0.12.1. Versions must be in sync to work correctly. Please install matching versions of serverless-haskell from NPM and Stack by either pinning your NPM version to match stack, or adding an extra-dep in your stack.yaml to match the NPM version.

  1. Update package.json to pin serverless-haskell to 0.12.1.
  2. $ sls invoke local -f mypackage-func

... It does nothing. Ctl-C to quit

Other steps

I just tried to follow the Manual instructions, and encountered similar issues. This time it does exit eventually. It looks like the delay was from docker trying to download ghc.

What does this error mean?


  Error --------------------------------------------------

  Error: Error when running Stack: exit code: 1; Preparing to install GHC to an isolated location.
  This will not interfere with any system-level installation.
  Preparing to download ghc-8.8.3 ...
  Already downloaded.
  /Users/seanhess/.stack/programs/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/ghc-8.8.3.temp/ghc-8.8.3: removeDirectoryRecursive:removeContentsRecursive:removePathRecursive:removeContentsRecursive:removeDirectory: unsatisfied constraints (Directory not empty)
  Stack command: stack --docker --docker-image fpco/stack-build:lts-13.30 --no-nix ls dependencies
      at new ProcessError (/Users/seanhess/Documents/learn/mypackage/node_modules/serverless-haskell/dist/index.js:47:28)
      at ServerlessPlugin.runStack (/Users/seanhess/Documents/learn/mypackage/node_modules/serverless-haskell/dist/index.js:118:19)
      at ServerlessPlugin.runStackOutput (/Users/seanhess/Documents/learn/mypackage/node_modules/serverless-haskell/dist/index.js:123:27)
      at ServerlessPlugin.assertServerlessPackageVersionsMatch (/Users/seanhess/Documents/learn/mypackage/node_modules/serverless-haskell/dist/index.js:164:38)
      at /Users/seanhess/Documents/learn/mypackage/node_modules/serverless-haskell/dist/index.js:230:19
      at Array.forEach (<anonymous>)
      at ServerlessPlugin.buildHandlers (/Users/seanhess/Documents/learn/mypackage/node_modules/serverless-haskell/dist/index.js:214:34)
      at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:476:55
      at tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Object.gotValue (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:168:18)
      at Object.gotAccum (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:155:25)
      at Object.tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.4.0
     Framework Version:         1.74.1
     Plugin Version:            3.6.15
     SDK Version:               2.3.1
     Components Version:        2.31.7

System information

Mac OSX Catalina

sls --version
Framework Core: 1.74.1
Plugin: 3.6.15
SDK: 2.3.1
Components: 2.31.7

stack --version
Version 2.3.1 x86_64 hpack-0.33.0

Error while building via docker within a docker container

I'm packaging/deploying a serverless-haskell project via my CI server. The CI server fires up a docker container to run my build scripts, therefore the command sls deploy is being run from within a docker container. The original build container is being run with the following command:

docker run -v /var/run/docker.sock:/var/run/docker.sock ubuntu:18.04

Inside this docker container, it seems that sls is doing the following...

/usr/bin/docker run -v /usr/local/bin/stack:/tmp/stack sha256:093b06222f1f8b2c25252d43c0e3242e475121ae135dd6d0ccdef5a2cc8c494b /tmp/stack --version

...which is failing because sls is expecting /usr/local/bin/stack to be present in whatever machine is running this command. However, given my setup, the docker volume mount is happening from the underlying host (not the build container), which doesn't have /usr/local/bin/stack

Is there any way around this? Can this one step be skipped or does the final build process also need to mount other directories?

Node 10.x missing library error

Howdy, when we try to run using the selected 10.x runtime, our lambda times out and we get this error:

error while loading shared libraries: libldap_r-2.4.so.2: cannot open shared object file: No such file or directory

Changing the runtime manually back to 8.10 allows the function to run.

Fails to build on LTS 11 (was: instructions in readme result in error)

i am trying to use this, and when i run sls deploy i get:

04:27 PM noon ∈ lf-test-hs ♫ sls deploy
Serverless: Package version mismatch: NPM: 0.4.2, Stack: undefined. Versions must be in sync to work correctly.
 
  Error --------------------------------------------------
 
  Package version mismatch.
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           9.9.0
     Serverless Version:     1.26.1
 

taking a look at the code, it seems the problem is that i do not have serverless-haskell as a dependency:

04:29 PM noon ∈ lf-test-hs ♫ stack ls dependencies --depth 1
aeson 1.2.4.0
base 4.10.1.0
lf-test-hs 0.1.0.0

i'm using lts-11.2.

i also can't actually find a build configuration in the stack.yaml that lets me actually build serverless-haskell.

i tried allow-newer: true and even that failed with some build error way down the line.

:(

Support deployment of projects located in sub-directories

serverless-haskell currently expects the stack project to be located at the same level as serverless.yml. A handler of the form src1/src2/packagename.handlername is not supported.

I have made a fix for this which supports both the case where the stack project is at the same level, and the case where it isn't. I can make a pull request for this if desired.

Package version mismatch: NPM: 0.7.1, Stack: 0.6.3 on lts-12.2

With lts-12.2 I'm currently getting a package version mismatch, which I'm not quite sure how to debug :/

A minimal project that runs into it is https://github.com/Tehnix/ServHs/tree/7eb997d5e39cd256bd900b050a605846d9f28d68.

$ SLS_DEBUG=* yarn sls invoke local --function entry
...
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Invoke invoke:local
Serverless: Building handler with Stack...
ServHs-0.1.0.0: unregistering (local file changes: README.md)
ServHs-0.1.0.0: build (lib + exe)
Preprocessing library for ServHs-0.1.0.0..
Building library for ServHs-0.1.0.0..
ignoring (possibly broken) abi-depends field for packages
Preprocessing executable 'entry' for ServHs-0.1.0.0..
Building executable 'entry' for ServHs-0.1.0.0..
ServHs-0.1.0.0: copy/register
Installing library in /Users/tehnix/GitHub/Tehnix/ServHs/.stack-work/install/x86_64-osx/lts-12.2/8.4.3/lib/x86_64-osx-ghc-8.4.3/ServHs-0.1.0.0-EOEdRPhD4y0Iek8gkVmCM0
Installing executable entry in /Users/tehnix/GitHub/Tehnix/ServHs/.stack-work/install/x86_64-osx/lts-12.2/8.4.3/bin
Registering library for ServHs-0.1.0.0..
Serverless: Package version mismatch: NPM: 0.7.1, Stack: 0.6.3. Versions must be in sync to work correctly.

  Error --------------------------------------------------

  Package version mismatch.

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: Package version mismatch.
    at ServerlessPlugin.assertServerlessPackageVersionsMatch (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless-haskell/index.js:175:19)
    at service.getAllFunctions.forEach.funcName (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless-haskell/index.js:258:18)
    at Array.forEach (<anonymous>)
    at ServerlessPlugin.buildHandlers (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless-haskell/index.js:240:35)
    at ServerlessPlugin.buildHandlersLocal (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless-haskell/index.js:213:14)
    at BbPromise.reduce (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
    at PluginManager.invoke (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless/lib/classes/PluginManager.js:390:22)
    at PluginManager.run (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless/lib/classes/PluginManager.js:421:17)
    at variables.populateService.then.then (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless/lib/Serverless.js:163:33)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
    at Serverless.run (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless/lib/Serverless.js:150:8)
    at serverless.init.then (/Users/tehnix/GitHub/Tehnix/ServHs/node_modules/serverless/bin/serverless:42:50)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.7.0
     Serverless Version:     1.28.0

error Command failed with exit code 1
  • stack version 1.7.1
  • npm version 6.2.0
  • yarn version 1.7.0

Let me know if you need any other details!

arguments is a reserved word in Javascript

Hello, thanks for great tool, I'm trying to launch some test project with it and have encountered the problem with Node environment, the error is:

START RequestId: 61730031-fc71-11e7-bc7b-35986d9cfc05 Version: $LATEST
Syntax error in module 'serverless-lambda-test': SyntaxError
    const arguments = options['arguments'];
                                         ^
SyntaxError: Identifier 'arguments' has already been declared
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
END RequestId: 61730031-fc71-11e7-bc7b-35986d9cfc05
REPORT RequestId: 61730031-fc71-11e7-bc7b-35986d9cfc05	Duration: 5.87 ms	Billed Duration: 100 ms 	Memory Size: 1024 MB	Max Memory Used: 21 MB	

As I understand this happened because arguments is reserved word in Javascript, so we cannot declare const with a such name :)

If it matters I have used Node runtime 6.10 and default settings/project from README.md (so to reproduce it is enough to go through all steps from README.md).

Versions 0.12.4+ throw TypeError: Cannot read property 'schema' of undefined

Hi
Can't work out quite what's going on but after upgrading from 11.3 -> 12.5 I get this:

  Type Error ---------------------------------------------

  TypeError: Cannot read property 'schema' of undefined
      at new ServerlessPlugin (/home/nick/workspace/HASKELL/sloganator.hs/node_modules/serverless-haskell/dist/index.js:115:35)
      at PluginManager.addPlugin (/home/nick/workspace/HASKELL/sloganator.hs/node_modules/serverless/lib/classes/PluginManager.js:78:28)
      at /home/nick/workspace/HASKELL/sloganator.hs/node_modules/serverless/lib/classes/PluginManager.js:115:31
      at Array.forEach (<anonymous>)
      at PluginManager.loadAllPlugins (/home/nick/workspace/HASKELL/sloganator.hs/node_modules/serverless/lib/classes/PluginManager.js:115:8)
      at /home/nick/workspace/HASKELL/sloganator.hs/node_modules/serverless/lib/Serverless.js:96:35
...etc..

with

Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              15.2.1
     Framework Version:         1.67.3
     Plugin Version:            3.8.4
     SDK Version:               2.3.2
     Components Version:        2.34.9

After downgrading it seems to stop (this, at least) in 0.12.3 so maybe the schema validation did something? I've checked the docs.

Issues with missing shared object dependencies when running in aws environment

Hello,

We're hitting some issues with dynamic library dependencies of a lambda deployed via this library.
I included as much details as I could gather (sorry if it's too much). Any help on this would be appreciated 😃

When I deploy the lambda by running npx sls deploy and do a test run of it in AWS, I'm getting the following error:

START RequestId: 07ef6bc4-ef85-49bf-82eb-8a73a1e313c3 Version: $LATEST
./r-executor-cleanup: /lib64/libldap_r-2.4.so.2: no version information available (required by /var/task/libpq.so.5)
./r-executor-cleanup: /lib64/libm.so.6: version `GLIBC_2.23' not found (required by /var/task/libquadmath.so.0)
END RequestId: 07ef6bc4-ef85-49bf-82eb-8a73a1e313c3
REPORT RequestId: 07ef6bc4-ef85-49bf-82eb-8a73a1e313c3 Duration: 26.71 ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 6 MB
RequestId: 07ef6bc4-ef85-49bf-82eb-8a73a1e313c3 Error: Runtime exited with error: exit status 1 Runtime.ExitError

The lambda looks like this so far (but the binary has all our required haskell dependencies)

module Our.Module.Name where
import AWSLambda (lambdaMain)
import Data.Aeson (Value)

lambda :: IO ()
lambda = lambdaMain cleanupHandler

cleanupHandler :: Value -> IO ()
cleanupHandler _ = putTextLn "TODO implement me"

build environment

We tested building the lambda in couple of environments, each time the error we got when running Test in aws was the same:

  • Linux 5.8.8, Fedora 32
  • Linux 5.4.62, NixOS 21.03
  • MacOS

We're building our project using stack lts-16.2,
we tried both with serverless-haskell 0.11.3 (included in the lts-16.2 snapshot) as well as with the latest version from hackage (0.12.1 - added to stack.yaml inside extra-deps)
Our package.json looks like this:

package.json
{
  "name": "pi-haskell-lambdas",
  "version": "0.1.0",
  "description": "Config for building and deploying haskell lambdas via serverless framework",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "serverless": "^1.83.0",
    "serverless-haskell": "^0.12.1"
  }
}
  

Addition info + things we tried:

As for the two .so files mentioned in the error log:
libpq.so.5 - is dependency of postgresql-simple that we're using
libquadmath.so.0 - this is dependency of some of the linear algebra / machine learning libs our app is using

Which files end up in the .serverless/r-executor-cleanup.zip ?
$ unzip .serverless/r-executor-cleanup.zip
$ ldd r-executor-cleanup  # This is our  main binary packaged in the zip
	linux-vdso.so.1 (0x00007ffc1b37f000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fedba2e3000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fedba2c1000)
	libpq.so.5 => /lib64/libpq.so.5 (0x00007fedba270000)
	libutil.so.1 => /lib64/libutil.so.1 (0x00007fedba26b000)
	libblas.so.3 => /lib64/libblas.so.3 (0x00007fedba214000)
	liblapack.so.3 => /lib64/liblapack.so.3 (0x00007fedb9b69000)
	libgsl.so.19 => not found
	libgslcblas.so.0 => /lib64/libgslcblas.so.0 (0x00007fedb9b24000)
	libz.so.1 => /lib64/libz.so.1 (0x00007fedb9b0a000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fedb9aff000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fedb9af8000)
	libgmp.so.10 => /lib64/libgmp.so.10 (0x00007fedb9a61000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fedb9895000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fedba449000)
	libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007fedb97fe000)
	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007fedb9511000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fedb94ba000)
	libldap_r-2.4.so.2 => /lib64/libldap_r-2.4.so.2 (0x00007fedb9460000)
	libgfortran.so.5 => /lib64/libgfortran.so.5 (0x00007fedb9195000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fedb90a8000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007fedb908f000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fedb9088000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fedb9076000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fedb906f000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fedb9055000)
	liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007fedb9042000)
	libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007fedb9022000)
	libquadmath.so.0 => /lib64/libquadmath.so.0 (0x00007fedb8fd8000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fedb8fbd000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fedb8f90000)
	libcrypt.so.2 => /lib64/libcrypt.so.2 (0x00007fedb8f53000)
	libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fedb8eba000)
  
What version of GLIBC do the ".so" files depend on?
$ for binary in r-executor-cleanup *.so.*; do echo $binary; objdump -T $binary | grep -o -E 'GLIBC_[0-9.]+' | sort -u; done
r-executor-cleanup
GLIBC_2.10
GLIBC_2.12
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.4
GLIBC_2.7
GLIBC_2.8
libasn1.so.8
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.8
libblas.so.3
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
libcrypto.so.1.0.0
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.7
libcrypt.so.1
GLIBC_2.14
GLIBC_2.2.5
libgfortran.so.3
GLIBC_2.14
GLIBC_2.17
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.6
GLIBC_2.7
libgnutls.so.30
GLIBC_2.14
GLIBC_2.15
GLIBC_2.17
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.8
libgslcblas.so.0
GLIBC_2.2.5
GLIBC_2.3.4
libgsl.so.19
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.7
libgssapi.so.3
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.4
GLIBC_2.8
libhcrypto.so.4
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.7
libheimbase.so.1
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.8
libheimntlm.so.0
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.4
libhogweed.so.4
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.4
libhx509.so.5
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.8
libidn.so.11
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.4
libkrb5.so.26
GLIBC_2.14
GLIBC_2.15
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.7
GLIBC_2.8
liblapack.so.3
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.4
liblber-2.4.so.2
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
libldap_r-2.4.so.2
GLIBC_2.12
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.4
GLIBC_2.4
libnettle.so.6
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
libpq.so.5
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
libquadmath.so.0
GLIBC_2.10
GLIBC_2.14
GLIBC_2.23
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
libroken.so.18
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.8
libsasl2.so.2
GLIBC_2.14
GLIBC_2.15
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.3.4
GLIBC_2.4
libsqlite3.so.0
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
libssl.so.1.0.0
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
libwind.so.0
GLIBC_2.14
GLIBC_2.2.5
GLIBC_2.3.4
GLIBC_2.4
  

Where do the .so files, that end up in the zip package come from?

I added some logging between these 2 lines and this is what I get as part of npx sls package:

output
$ npx sls package
Serverless: Building handler r-executor-cleanup with Stack...
# ...
# stack build log omitted
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libpq.so.5 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libpq.so.5
Serverless: Running stack exec cp /usr/lib/libblas.so.3 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libblas.so.3
Serverless: Running stack exec cp /usr/lib/liblapack.so.3 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/liblapack.so.3
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libgsl.so.19 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libgsl.so.19
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libgslcblas.so.0 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libgslcblas.so.0
Serverless: Running stack exec cp /lib/x86_64-linux-gnu/libssl.so.1.0.0 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libssl.so.1.0.0
Serverless: Running stack exec cp /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libcrypto.so.1.0.0
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libldap_r-2.4.so.2
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libgfortran.so.3 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libgfortran.so.3
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/liblber-2.4.so.2
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libsasl2.so.2 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libsasl2.so.2
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libgssapi.so.3 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libgssapi.so.3
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libgnutls.so.30 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libgnutls.so.30
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libquadmath.so.0 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libquadmath.so.0
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libheimntlm.so.0
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libkrb5.so.26 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libkrb5.so.26
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libasn1.so.8 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libasn1.so.8
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libhcrypto.so.4
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libroken.so.18 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libroken.so.18
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libidn.so.11 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libidn.so.11
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libnettle.so.6 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libnettle.so.6
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libhogweed.so.4 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libhogweed.so.4
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libwind.so.0 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libwind.so.0
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libheimbase.so.1 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libheimbase.so.1
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libhx509.so.5 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libhx509.so.5
Serverless: Running stack exec cp /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libsqlite3.so.0
Serverless: Running stack exec cp /lib/x86_64-linux-gnu/libcrypt.so.1 /home/jhrcek/Devel/github.com/Holmusk/PI/backend/libcrypt.so.1
Serverless: Packaging service...
  

The issue is reproducible locally

When I run npx sls invoke local -f r-executor-cleanup locally
I see an active docker container, which seems to be doing nothing (for 30 minutes).

docker ps -a --no-trunc
CONTAINER ID                                                       IMAGE                 COMMAND                                         CREATED             STATUS              PORTS               NAMES
cfdb5dcd255da7edbbdd25cc0f5769aa6f99278493406df80befc0003e7d93a4   sls-docker-provided   "/var/runtime/init ./r-executor-cleanup \"\""   58 seconds ago      Up 57 seconds                           distracted_blackburn

And when I do docker kill <CONTAINER_ID> the following appears in terminal, where I executed the above command:

output
Serverless: Packaging service...
# At this point I execute `docker kill...`
./r-executor-cleanup: /lib64/libldap_r-2.4.so.2: no version information available (required by /var/task/libpq.so.5)
./r-executor-cleanup: /lib64/libm.so.6: version `GLIBC_2.23' not found (required by /var/task/libquadmath.so.0)

Error --------------------------------------------------

Error: Failed to run docker for provided image (exit code 137})
at /home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:537:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)

 For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com

Your Environment Information ---------------------------
Operating System: linux
Node Version: 12.16.1
Framework Version: 1.83.0 (local)
Plugin Version: 3.8.4
SDK Version: 2.3.1
Components Version: 2.34.9

Note that this corresponds to the error we're getting when testing the lambda in AWS console.

Permission errors

/var/task is owned by aws_user:1000 now, but lambci/lambda:build-provided.al2 runs as sbx_user1051, which makes sls offline start die with permission errors like not being able to access /var/task.

How can this be rectified?

Using sls yaml config:

plugins:
  - serverless-haskell
  - serverless-offline

custom:
  haskell:
    docker: true
  serverless-offline:
    useDocker: true
    printOutput: true

Ta!

Error while building serverless-haskell 0.8.7 with stack lts-13.19 on macOS

Hello,

I am trying to run the example project on macOS Mojave (10.14.04).

I am getting the following error:

uk05182:haskelllambda jakob$ stack install 
serverless-haskell-0.8.7: configure
serverless-haskell-0.8.7: build
Progress 1/2

--  While building package serverless-haskell-0.8.7 using:
      /Users/jakob/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/jakob/private_projects/haskelllambda/.stack-work/logs/serverless-haskell-0.8.7.log

    Configuring serverless-haskell-0.8.7...
    Preprocessing library for serverless-haskell-0.8.7..
    Building library for serverless-haskell-0.8.7..
    [ 1 of 13] Compiling AWSLambda.Events.Records ( src/AWSLambda/Events/Records.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/AWSLambda/Events/Records.o )
    <command line>: can't load .so/.DLL for: /Users/jakob/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSzlib-0.6.2-BdOecmQ0rL1HOiGypdSgxY-ghc8.6.4.dylib (dlopen(/Users/jakob/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSzlib-0.6.2-BdOecmQ0rL1HOiGypdSgxY-ghc8.6.4.dylib, 5): Symbol not found: _deflateEnd
      Referenced from: /Users/jakob/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSzlib-0.6.2-BdOecmQ0rL1HOiGypdSgxY-ghc8.6.4.dylib
      Expected in: flat namespace
     in /Users/jakob/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSzlib-0.6.2-BdOecmQ0rL1HOiGypdSgxY-ghc8.6.4.dylib)

My steps:

  1. Clone project
  2. Change resolver in stack.yml to lts-13.19
  3. Execute stack build or stack install (both fail)

I tried using lts-13.11 but ran into the same issue.

Could not find serverless-haskell in stack's dependencies

Trying to go through your readme and when I get to sls deploy I receive the following error message:

> npx sls deploy
Pulling image from registry: 'fpco/stack-build:lts-12.9'
lts-12.9: Pulling from fpco/stack-build
Digest: sha256:fdbabc6df1135ab640041c966a2f8ced3bdaff7226de4a41f52d8c08fc9d64c7
Status: Image is up to date for fpco/stack-build:lts-12.9
Serverless: Could not find serverless-haskell in stack's dependencies. Make sure serverless-haskell you are using LTS 12 (or newer), or add it as an extra-dep in your stack.yaml.

  Error --------------------------------------------------

  Package not found.

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           8.11.3
     Serverless Version:     1.31.0

I have added the following to my stack.yaml file

extra-deps:
- serverless-haskell-0.7.5

I'm sure that this is something easy that I'm missing

Socket hangs up after some time in serverless offline, and keeps going in invoke local

I am not sure if this is related to #28, but sockets seem to hang up both when using serverless offline start and invoke local.

$ yarn sls offline start
Serverless: Building handler with Stack...
...
Serverless: GET /hello/bla (λ: gateway-entry)
This should go to logs
Serverless: [200] {"body":"Hello, bla\n","headers":{},"statusCode":200}
Error: socket hang up
    at createHangUpError (_http_client.js:313:15)
    at TLSSocket.socketOnEnd (_http_client.js:416:23)
    at TLSSocket.emit (events.js:187:15)
    at TLSSocket.EventEmitter.emit (domain.js:442:20)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.
$ yarn sls invoke local --function entry --data '{}'
...
This should go to logs
Object (fromList [])
"Went into handler"
Error: socket hang up
    at createHangUpError (_http_client.js:313:15)
    at TLSSocket.socketOnEnd (_http_client.js:416:23)
    at TLSSocket.emit (events.js:187:15)
    at TLSSocket.EventEmitter.emit (domain.js:442:20)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.

I'd also expect invoke local to exit immediately after the response, but I am not sure what the intended effect is here.

Request to support amazonka 2.0

Hello @koterpillar,
since amazonka 2.0 release candidate is out (brendanhay/amazonka#716)
I'd like to upgrade to it, but this will require this library to migrate to it too.
Are you planning to upgrade this library to support it?

If you're too busy, I could try opening a PR (not sure yet how much effort it would be). I opened an initial PR to help you preview the necessary changes.

Would you prefer to support both <2.0 and >=2.0 version of amazonka or would you be ok with moving to >=2.0 only?
The former would likely require lots of CPP..

Use new lambda capabilities for native haskell runtime

I had been thinking about trying to write a wrapper process based on a node extension to address #24 and #26 but that involved a lot of strange chicanery, especially as we'd have a C shim between Node and Haskell, so it'd get gross.

If we can bind to the new C++ runtime API that seems like the easiest and best route to a genuinely native Haskell runtime.

If no one else is working on this, I'm inclined to take a shot at it, especially if it can all be done through ctypes. My inclination is to write a separate package that calls into the API rather than adding to this, unless it winds up needing some of the types already nicely defined here.

Any thoughts?

Build failures after switching to `haskell:stretch`

Today I tried upgrading from serverless-haskell from 0.12.5 to 0.12.6

With 0.12.5 my lambdas are building fine.
But after upgrade to 0.12.6 I started getting failures like this:

...
postgresql-libpq           > Configuring postgresql-libpq-0.9.4.2...
postgresql-libpq           > setup: The program 'pg_config' is required but it could not be found.
...
...
--  While building package postgresql-libpq-0.9.4.2 (scroll up to its section to see the error) using:
...

 Error ---------------------------------------------------
...
  Error: Error when running Stack: exit code: 1
  Stack command: stack --docker --docker-image haskell:stretch --no-nix build
      at new ProcessError (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:76:28)
      at ServerlessPlugin.runStack (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:158:19)
      at /home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:276:19
      at Array.forEach (<anonymous>)
      at ServerlessPlugin.buildHandlers (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless-haskell/dist/index.js:254:34)
      at PluginManager.invoke (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/lib/classes/PluginManager.js:576:20)
      at async PluginManager.run (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/lib/classes/PluginManager.js:634:7)
      at async Serverless.run (/home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/lib/Serverless.js:427:5)
      at async /home/jhrcek/Devel/github.com/Holmusk/PI/backend/node_modules/serverless/scripts/serverless.js:650:9

I suspect the reason might be this:
My application depends on postgresql-simple, which in turn depends on libpq-devel C library.
This dependency was probably present in the fpco/stack-build:lts-13.30, but is no longer provided by the new haskell:stretch image:

$ docker run -it fpco/stack-build:lts-13.30 /bin/bash
root@f4a5ce57efce:/# pkg-config --list-all | grep libpq
libpq                               libpq - PostgreSQL libpq library


$ docker run -it haskell:stretch  /bin/bash
root@91a83277f13e:/# pkg-config --list-all | sort
form      form - ncurses 6.0 add-on library
menu      menu - ncurses 6.0 add-on library
ncurses   ncurses - ncurses 6.0 library
ncurses++ ncurses++ - ncurses 6.0 add-on library
panel     panel - ncurses 6.0 add-on library
sqlite3   SQLite - SQL database engine
tic       tic - ncurses 6.0 add-on library
tinfo     tinfo - ncurses 6.0 terminal interface library
zlib      zlib - zlib compression library

`invoke local` is not supported

Hi. New to Serverless so maybe I'm doing it wrong, but:

Steps

  • Check out and build example project
  • Verify that sls invoke hello -d "[1, 100, 10]" correctly returns "Highest value is 100"
  • Then run sls invoke local hello -d "[1, 100, 10]"

Expected

  • Same result, i.e. "Highest value is 100"

Actual

Errors with:

{ Error: Cannot find module '/home/nick/workspace/GITHUB/serverless-haskell/example-project/serverless-haskell-example'                                                            
    at Function.Module._resolveFilename (module.js:547:15)                               
    at Function.Module._load (module.js:474:25)                                          
    at Module.require (module.js:596:17)    
    at require (internal/module.js:11:18)   
    at AwsInvokeLocal.invokeLocalNodeJs (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:258:33)       
    at AwsInvokeLocal.invokeLocal (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:125:19)             
    at AwsInvokeLocal.tryCatcher (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/util.js:16:23)                                   
    at Promise._settlePromiseFromHandler (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/promise.js:512:31)                       
    at Promise._settlePromise (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/promise.js:569:18)                                  
    at Promise._settlePromise0 (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/promise.js:614:10)                                 
    at Promise._settlePromises (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/promise.js:693:18)                                 
    at Async._drainQueue (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/async.js:133:16)                                         
    at Async._drainQueues (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/async.js:143:10)                                        
    at Immediate.Async.drainQueues (/home/nick/workspace/GITHUB/serverless-haskell/example-project/node_modules/bluebird/js/release/async.js:17:14)                                
    at runCallback (timers.js:794:20)       
    at tryOnImmediate (timers.js:752:5)     
    at processImmediate [as _immediateCallback] (timers.js:729:5) code: 'MODULE_NOT_FOUND' }                                                                                       
Done in 0.66s.                              

sls deploy throws `fs.copyFileSync is not a function`

I'm not sure if I'm missing any steps, but I'm unable to run sls deploy on either my own project or the example one, with the same error:

sls deploy -v
Pulling image from registry: 'fpco/stack-build:lts-9.17'
lts-9.17: Pulling from fpco/stack-build
Digest: sha256:d01545998a8bf2407e3c0e3c2c4b5fa5d00bd9fe449f5d4be388445d6dada741
Status: Image is up to date for fpco/stack-build:lts-9.17

  Type Error ---------------------------------------------

  fs.copyFileSync is not a function

I've tried first doing

  • npm install from example-project
  • npm install from serverless-plugin
  • npm install -g fs-extra
  • manually running stack build --docker from example-project first

fatal error exe is not defined

I have written a simple servant server and converted it into a lambda function that queries a MySQL db in amazon RDS. I can get it to work locally with serverless offline start however when I deploy it (serverless deploy) I get the following error in my dashboard when trying to access my simple test endpoint.

10:24:00 am
START RequestId: 9577f510-712c-4204-b9ac-05d75defcb42 Version: $LATEST
10:24:00 am
2019-10-28T14:24:00.167Z	9577f510-712c-4204-b9ac-05d75defcb42	INFO	
10:24:00 am
2019-10-28T14:24:00.169Z	9577f510-712c-4204-b9ac-05d75defcb42	ERROR	ReferenceError: exe is not defined
    at Object.<anonymous> (/var/task/s_apigw.js:14:66)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at _tryRequire (/var/runtime/UserFunction.js:75:12)
    at _loadUserApp (/var/runtime/UserFunction.js:95:12)
10:24:00 am
2019-10-28T14:24:00.185Z	9577f510-712c-4204-b9ac-05d75defcb42	ERROR	Invoke Error	{
    "errorType": "ReferenceError",
    "errorMessage": "exe is not defined",
    "stack": [
        "ReferenceError: exe is not defined",
        "    at Object.<anonymous> (/var/task/s_apigw.js:14:66)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
        "    at Module.load (internal/modules/cjs/loader.js:653:32)",
        "    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
        "    at Module.require (internal/modules/cjs/loader.js:692:17)",
        "    at require (internal/modules/cjs/helpers.js:25:18)",
        "    at _tryRequire (/var/runtime/UserFunction.js:75:12)",
        "    at _loadUserApp (/var/runtime/UserFunction.js:95:12)"
    ]
}
10:24:00 am
END RequestId: 9577f510-712c-4204-b9ac-05d75defcb42
10:24:00 am
REPORT RequestId: 9577f510-712c-4204-b9ac-05d75defcb42	Duration: 30.73 ms	Billed Duration: 100 ms	Memory Size: 1024 MB	Max Memory Used: 83 MB	Init Duration: 210.80 ms	

Stack template

stack new serverless-haskell should produce a project ready to be deployed. Note: no new Stack templates are currently accepted pending a refactor.

Error: child process output bad JSON

I'm currently getting this error from my AWS apigateway api using Postman:

{
    "errorType": "Error",
    "errorMessage": "child process output bad JSON: ",
    "stack": [
        "Error: child process output bad JSON: ",
        "    at _homogeneousError (/var/runtime/CallbackContext.js:13:12)",
        "    at postError (/var/runtime/CallbackContext.js:30:51)",
        "    at done (/var/runtime/CallbackContext.js:57:7)",
        "    at fail (/var/runtime/CallbackContext.js:69:7)",
        "    at /var/runtime/CallbackContext.js:105:16",
        "    at process._tickCallback (internal/process/next_tick.js:68:7)"
    ]

My json payload is as follows:

{ "resource" : "/updatepic"
, "body" : "pleasework"}

My end point is: https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/updatepic

I'm not sure if I'm formatting my JSON payload correctly. I've tried many variations but I'm getting timeouts and the bad JSON error above.

If I don't put any payload in my POST request my lamba function continues to execution and outputs "not enough input"/

This is my "event" JSON parser:

instance FromJSON Event where
  parseJSON = withObject "Event" $ \v -> do
    bd <- v .: "body"
    rs <- v .: "resource"
    pure $ Event bd rs

And this is my serverless.yml

service: hailmeout-production

provider:
  name: aws
  runtime: haskell
  region: us-east-1
  timeout: 30

functions:
  servantserver:
    handler: servantBackend.backend
    events:
      - http:
          path: updatepic
          method: post
          cors: true

plugins:
  - serverless-haskell
  - serverless-offline

Deploy fails when using master / rootless Docker

Can we get it to allow non-normally-versioned Dockers?

npx sls deploy output:
Error: Error when running Stack: Cannot get Docker version (invalid 'docker --version' output)
docker --version output:
Docker version master-dockerproject-2019-07-12, build 6fc0dc91
Docker installed via:
curl -sSL https://get.docker.com/rootless | sh

Ta!

Offline even with `--useDocker` tries to use lambci/lambda:haskell which doesn't exist

offline: Warning: found unsupported runtime 'haskell' for function 'emailme'
No valid trust data for haskell
offline: Failure: Command failed with exit code 1: docker pull --disable-content-trust=false lambci/lambda:haskell
No valid trust data for haskell
Error: Command failed with exit code 1: docker pull --disable-content-trust=false lambci/lambda:haskell
No valid trust data for haskell
    at makeError (/home/dwd/code/mine/projects/haskell/slsdemo/node_modules/serverless-offline/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/home/dwd/code/mine/projects/haskell/slsdemo/node_modules/serverless-offline/node_modules/execa/index.js:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Function._pullImage (/home/dwd/code/mine/projects/haskell/slsdemo/node_modules/serverless-offline/dist/lambda/handler-runner/docker-runner/DockerImage.js:35:7)

Tried to use provided as runtime but I just get:

offline: [502] {"errorType":"exitError","errorMessage":"RequestId: 2cf06505-d533-17c1-57a0-edde6a345edc Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]"}

Any ideas?

Example project not compiling

Hey there - first off: thanks for this nice techology.

Unfortunately I now spent two hours and could not get it to work. I tried cloning the example project and creating one from scratch. I always run into the following error:

~/example-project   
❯ sls invoke local -f hello
Serverless: Package version mismatch: NPM: 0.7.5, Stack: 0.6.7. Versions must be in sync to work correctly. Please install matching versions of NPM and Stack packages by either pinning your NPM version to match stack, or adding an extra-dep in your stack.yaml to match the NPM version.
 
  Error --------------------------------------------------
 
  Package version mismatch.
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           8.12.0
     Serverless Version:     1.32.0

Note: I am fairly new to haskell development.
I tried

  • adding extra-dep to stack.yaml but the npm package was not found in the registry. Downgrading to an old version of NPM was not straightforward plus I do not get why the version of NPM would be relevant. Is the message maybe referring to NodeJS rather than NPM?
  • Why do I need a realy old version of stack for this to work?
    It would be nice if the example project would be working with the latest or modern versions of stack and node.
  • I could not find documentation on the error message.
  • I have no clue what to sync with what as I could not find configuration pointing to the versions mentioned in the error message.

`sls deploy` fails with no error message when building with static linking

After adding ld-options: -static -pthread to my .cabal, sls deploy fails in the stack build step with no error message. During the build, stack issues a bunch of warnings like Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking", but no actual error messages. Yet for whatever reason the process returns status code 1.

Odder still, when I change the fail condition in the runStack function from result.status > 0 to result.status > 1, the executable gets deployed and runs successfully.

Considering that static linking is often necessary for deployment to serverless, there should be some better handling for this case, and we should also look upstream to figure out why stack is returning an error code.

Use `http-types` types in request and response

There's a fairly standard set of types for these defined https://hackage.haskell.org/package/http-types. wai (Web Application Interface) depends on them directly. Beyond the general benefits of standardization, using the standards here would make it slightly easier to package up WAI applications for use with API Gateway.

Here's a rough draft of that:

{-# LANGUAGE FlexibleContexts  #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards   #-}
{-# LANGUAGE TypeApplications  #-}

module Main where

import           AWSLambda.Events.APIGateway as AWS hiding (requestBody)
import qualified AWSLambda.Events.APIGateway as AWS
import           Control.Lens
import           Control.Monad               ((<=<))
import qualified Data.Aeson.TextValue        as Aeson
import           Data.ByteString             (ByteString)
import           Data.ByteString.Builder     (toLazyByteString)
import qualified Data.ByteString.Lazy        as Lazy
import qualified Data.CaseInsensitive        as CI
import           Data.Convertible            (Convertible, convert)
import qualified Data.HashMap.Strict         as HashMap
import           Data.IORef                  (IORef, modifyIORef', newIORef,
                                              readIORef, writeIORef)
import           Data.Maybe
import           Data.Semigroup              ((<>))
import           Data.Text                   (Text, splitOn)
import           Network.HTTP.Types          as HTTP
import qualified Network.Wai                 as Wai
import           Network.Wai.Handler.Warp    (runEnv)
import qualified Network.Wai.Internal        as Wai
import           System.Environment          (lookupEnv)

echo :: Wai.Application
echo req sendResponse =
  sendResponse . Wai.responseLBS HTTP.ok200 mempty =<< Wai.strictRequestBody req

main :: IO ()
main = do
  useWarp <- lookupEnv "WARP"
  case useWarp of
    Just _  -> runEnv 8000 echo
    Nothing -> apiGatewayMain . wrapper @Text @Text $ echo

wrapper ::
     (Eq t, Monoid t, Convertible Lazy.ByteString t, Convertible s ByteString)
  => Wai.Application
  -> APIGatewayProxyRequest s
  -> IO (APIGatewayProxyResponse t)
wrapper app req =
  fromWaiResponse . fromJust <=< withIORef Nothing $ \responseRef -> do
    first <- newIORef True
    app
      (toWaiRequest first req)
      (fmap (const Wai.ResponseReceived) . writeIORef responseRef . Just)

toWaiRequest ::
     (Convertible t ByteString)
  => IORef Bool
  -> APIGatewayProxyRequest t
  -> Wai.Request
toWaiRequest first req = Wai.Request {..}
  where
    requestMethod = req ^. agprqHttpMethod . to convert
    httpVersion = error "No HTTP version"
    rawPathInfo = req ^. agprqPath . to convert
    rawQueryString = error "No raw query string"
    requestHeaders =
      req ^.. agprqHeaders . to itoList . traverse .
      to (bimap (CI.mk . convert) convert)
    isSecure = error "Not HTTP or HTTPS"
    remoteHost = error "No remote host"
    pathInfo = req ^. agprqPath . to (splitOn "/")
    queryString =
      req ^.. agprqQueryStringParameters . to itoList . traverse .
      to (bimap convert (Just . convert))
    requestBody' = req ^? AWS.requestBody . _Just . to convert
    requestBody = yieldOnce (fromMaybe mempty requestBody') first
    vault = mempty
    requestBodyLength = Wai.KnownLength . convert . length $ requestBody'
    requestHeaderHost = req ^? agprqHeaders . ix "Host" . to convert
    requestHeaderRange = req ^? agprqHeaders . ix "Range" . to convert
    requestHeaderReferer = req ^? agprqHeaders . ix "Referer" . to convert
    requestHeaderUserAgent = req ^? agprqHeaders . ix "User-Agent" . to convert

yieldOnce :: Monoid b => b -> IORef Bool -> IO b
yieldOnce payload ref = do
  first <- readIORef ref
  if first
    then payload <$ writeIORef ref False
    else mempty

withIORef :: b -> (IORef b -> IO a) -> IO b
withIORef a m = do
  ref <- newIORef a
  _ <- m ref
  readIORef ref

fromWaiResponse ::
     (Convertible Lazy.ByteString t, Eq t, Monoid t)
  => Wai.Response
  -> IO (APIGatewayProxyResponse t)
fromWaiResponse res = do
  _agprsBody <-
    waiBody $ \f ->
      fmap mungeBody . withIORef mempty $ \contentRef ->
        f (\chunk -> modifyIORef' contentRef (<> chunk)) mempty
  pure $ APIGatewayProxyResponse {..}
  where
    mungeBody = nonEmpty . convert . toLazyByteString
    nonEmpty x
      | x == mempty = Nothing
      | otherwise = Just (Aeson.TextValue x)
    (HTTP.Status _agprsStatusCode _, waiHeaders, waiBody) =
      Wai.responseToStream res
    _agprsHeaders =
      HashMap.fromList . fmap (bimap (convert . CI.original) (convert . id)) $
      waiHeaders

As you can see, toWaiRequest and fromWaiResponse would benefit a bit from better harmony with the standard.

Google Functions support

Thanks for the great library. I am looking a way to run serverless-haskell in Google Functions instead of AWS Lambda.

Aws Lambda with custom runtime support makes it pretty easy to create runtimes aside with officially supported languages. Google Functions doen't have custom runtimes support and I am trying to figure out if running haskell is even possible.

Do you have any idea on how to achieve this?

Cannot read property 'schema' of undefined

I followed the instructions,

stack new mypackage https://raw.githubusercontent.com/seek-oss/serverless-haskell/master/serverless-haskell.hsfiles
cd mypackage
npm install
stack build
sls invoke local -f mypackage-func

and got this,

Cannot read property 'schema' of undefined

Here is the SLS debug info,

sls invoke local -f mypackage-func
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
 
  Type Error ---------------------------------------------
 
  Cannot read property 'schema' of undefined
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
TypeError: Cannot read property 'schema' of undefined
    at new ServerlessPlugin (/Users/vifo/git/mypackage/node_modules/serverless-haskell/dist/index.js:115:35)
    at PluginManager.addPlugin (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:62:28)
    at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:102:14
    at Array.forEach (<anonymous>)
    at PluginManager.loadPlugins (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:98:13)
    at PluginManager.loadServicePlugins (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:151:10)
    at PluginManager.loadAllPlugins (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:94:10)
    at /usr/local/lib/node_modules/serverless/lib/Serverless.js:72:26
From previous event:
    at Serverless.init (/usr/local/lib/node_modules/serverless/lib/Serverless.js:70:8)
    at /usr/local/lib/node_modules/serverless/bin/serverless:42:21
    at processImmediate (internal/timers.js:461:21)
From previous event:
    at /usr/local/lib/node_modules/serverless/bin/serverless:28:46
    at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless:65:4)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     OS:                     darwin
     Node Version:           14.12.0
     Serverless Version:     1.43.0

I am opening this issue with the hopes of resolving this issue or updating the readme docs with steps to avert this issue for future users.

Stackage nighly compilation failure

/var/stackage/work/unpack-dir/unpacked/serverless-haskell-0.12.6-0aad6e7c1ea6e0a0f623b102101ff644049eb980a3c9c13889c31f73e8fc53cd/src/AWSLambda/Events/KinesisEvent.hs:18:1: error:
           Could not find module ‘Network.AWS.Data.Base64’
           Use -v (or `:set -v` in ghci) to see a list of the files searched for.
          |
       18 | import           Network.AWS.Data.Base64   (Base64 (..))
          | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

       /var/stackage/work/unpack-dir/unpacked/serverless-haskell-0.12.6-0aad6e7c1ea6e0a0f623b102101ff644049eb980a3c9c13889c31f73e8fc53cd/src/AWSLambda/Events/KinesisEvent.hs:19:1: error:
           Could not find module ‘Network.AWS.Kinesis.Types’
           Use -v (or `:set -v` in ghci) to see a list of the files searched for.
          |
       19 | import qualified Network.AWS.Kinesis.Types as Kinesis
          | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

       /var/stackage/work/unpack-dir/unpacked/serverless-haskell-0.12.6-0aad6e7c1ea6e0a0f623b102101ff644049eb980a3c9c13889c31f73e8fc53cd/src/AWSLambda/Events/KinesisEvent.hs:20:1: error:
           Could not find module ‘Network.AWS.Types’
           Perhaps you meant
             Network.DNS.Types (needs flag -package-id dns-4.2.0)
             Network.TLS.Types
             Network.S3.Types
           Use -v (or `:set -v` in ghci) to see a list of the files searched for.
          |
       20 | import qualified Network.AWS.Types         as AWS
          | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Disabled serverless-haskell in nightly build for now.

Check that the versions of JS and Haskell packages are the same

Only the same versions of the serverless plugin and the Haskell package are guaranteed to work. Updating the one means updating the other. Need to:

  • Document this
  • In serverless plugin, check the Haskell package version (stack list-dependencies --depth 1 | grep serverless-haskell)

glibc 2.27 missing if built on Ubuntu 18.04

I'm trying to deploy the example project, but it fails given that Ubuntu 18.04 is shipped with glibc 2.27, so when invoking the lambda it complains that it cannot find it.

Any ideas on how to fix this? Is there a docker image available for building this properly?

Support lts 14

serverless.yml

provider:
  runtime: haskell
  ...

plugins:
  - serverless-domain-manager
  - serverless-haskell
  - serverless-offline

...

package.json

{
    "devDependencies": {
        "serverless": "1.48.1",
        "serverless-domain-manager": "2.6.6",
        "serverless-haskell": "0.9.1",
        "serverless-offline": "5.12.0"
    }
}

stack.yml

resolver: lts-14.1

extra-deps:
  - morpheus-graphql-0.4.0
  - aeson-1.4.4.0
  - time-compat-1.9.2.2
  - serverless-haskell-0.9.1
  - amazonka-kinesis-1.6.1
  - amazonka-core-1.6.1
  - amazonka-s3-1.6.1

package.yml

dependencies:
  - base >= 4.7 && < 5
  - serverless-haskell >= 0.9.1
  - aeson
  - lens
  - bytestring
  - containers >= 0.4.2.1 && < 0.7
  - split
  - text
  - morpheus-graphql >= 0.4.0

...

with this configuration i try to run sls offline start

but it trows error:

 Type Error ---------------------------------------------

  TypeError: Cannot read property 'serverless-haskell' of undefined
      at ServerlessPlugin.assertServerlessPackageVersionsMatch (./mythology-api/node_modules/serverless-haskell/index.js:180:34)
      at deployedFunctions.forEach.funcName (./mythology-api/node_modules/serverless-haskell/index.js:287:18)
      at Array.forEach (<anonymous>)
      at ServerlessPlugin.buildHandlers (./mythology-api/node_modules/serverless-haskell/index.js:266:34)
      at ServerlessPlugin.buildHandlersLocal (./mythology-api/node_modules/serverless-haskell/index.js:222:14)

Example project times out

Sorry for raising another issue, but I can't really explain what is going on.

I have used the stack template to create a new project and updated the resolver to lts-13.19.

I can run the function locally without any issues and deploying it worked also fine.
Unfortunately, running the deployed function times out.

{
    "errorMessage": "2019-05-04T15:54:49.122Z 39a8c872-a36b-47d7-b84c-9d4e694b2029 Task timed out after 6.01 seconds"
}
 
  Error --------------------------------------------------
 
  Invoked function failed
 
  Your Environment Information ---------------------------
     OS:                     linux
     Node Version:           11.14.0
     Serverless Version:     1.41.1

I have played around with the deployed javascript file and it seems like waiting for the server is the culprit.

const socket = await connection;

I have put return { statusCode: 200, body: JSON.stringify('Hello from Lambda!')}; before this line and the lambda finishes fine. If I put it after awaiting the connection it times out.

Not sure if anyone can reproduce this or knows what I am doing wrong?

Add custom flag to allow deploying without building

This is just an idea / feature request.

I have been playing around with serverless-haskell for a few days now and it works quite well.
The only issue I can see is using it with continuous deployment.

I use Gitlab CI and I would love to be able to split building and deploying into 2 build steps.
This would require being able to invoke serverless deploy without building, but using an already built binary.

So basically I would love to be able to

  1. Build without docker
  2. Deploy binary built in step 1

Of course there might be a better way of doing this, it was just an idea I've had.
I am also willing to help building this if you think it is a good idea.

Google run

I belief you intend to Port this to Google, but they released cloud run which is serverless on containers. Between that and anthos, will delivering Google offering become priority.

Im not in love with aws, because of the above, aws doesnt deserve it :p.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.