theam / aws-lambda-haskell-runtime

⚡Haskell runtime for AWS Lambda
https://theam.github.io/aws-lambda-haskell-runtime/
Other
269 stars 48 forks source link

Testing locally with AWS SAM #98

Closed raghav-kukreti closed 3 years ago

raghav-kukreti commented 3 years ago

OS: Debian Stack: 2.5.1 GHC: 8.8.3

I've been trying to invoke the standard template's Handler (src/Lib.hs) locally to test, using sam local invoke -e query.json

where query.json simply contains: {"personName": "value1", "personAge": 22}

Till now, I've created a /template.yaml file which reads:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Lambda handlers f
Resources:
  svelteHaskell:
    Type: AWS::Serverless::Function
    Properties:
      Handler: handler
      Runtime: provided
      CodeUri: 'build/function.zip'
      Description: >
          Main Handler 

In place of handler I have tried various combinations which include:

All of which gives the same error on sam invoke: "Handler handler does not exist on project" Is there a proper way I should be testing this locally?

NickSeagull commented 3 years ago

Hello, thanks a lot for reporting!

Handlers are in the form src/Lib.handler, you can see the documentation of Configuring the dispatcher.

Note that with #97 probably this functionality will go away and you'll be able to specify the names yourself.

Feel free to reopen if the issue persists 😄

raghav-kukreti commented 3 years ago

Hi, Appreciate the help, Once I point it to the handler using src/Lib.handler, the sam build looks for a makefile in the build/ folder, once specifically with a build target named (extending from the first example) build-svelteHaskell.

Apologies for this rather verbose question, but what's the process of invoking SAM, and testing aws-lambda-haskell-runtime locally?

NickSeagull commented 3 years ago

I haven't used SAM myself along with this runtime, but some contributors left useful comments in this PR perhaps they'd be helpful