aws / aws-lambda-runtime-interface-emulator

Apache License 2.0
915 stars 95 forks source link

Is it possible to test LambdaFunctionURL lambdas with aws-lambda-rie ? #99

Open mpatou opened 11 months ago

mpatou commented 11 months ago

I have a 2 lambdas:

I'm able to successfully test with aws-lambda-riethe first Lambda but not the second one

Even with a quite naive handler:

func  Handle(ctx context.Context, request events.LambdaFunctionURLRequest) error {
  log.Printf("body: %s", request.RawPath)
  return nil
}

Is it possible to test this "new" kind of lambdas using aws-lambda-runtime ? Am I doing something wrong ?

bschulz87 commented 4 months ago

You have to setup the payload to match the LambdaFunctionURLRequest event. Take a look at https://github.com/aws/aws-lambda-go/blob/main/events/testdata/lambda-urls-request.json

Note that you have to stringify JSON for the "body" Field.