lambda-api icon indicating copy to clipboard operation
lambda-api copied to clipboard

Process AWS SDK “Invoke” requests

Open jeremydaly opened this issue 6 years ago • 2 comments
trafficstars

There should be a way for Lambda API to process requests that bypass API Gateway and are invoked directly. Support for “RequestResponse” and “Event” invocations should be supported.

jeremydaly avatar Apr 20 '19 11:04 jeremydaly

I have a use case where I would like to use lambda-api for a series of lambdas API Gateway. For testing/development purposes, I am invoking the lambda directly using the AWS Lambda client. When I do invoke the handler directly (setting the logger to debug) I see that the "route" is undefined, which results in a "Method not allowed" response. Are there any current workarounds that might be able to unblock at the moment? Thanks!

austinfox avatar Apr 27 '21 15:04 austinfox

@austinfox If you want to invoke your lambda-api handler without using API Gateway, you can try passing an event object that is similar to the API Gateway format. The following examples should work a sample requests:

{
  "httpMethod": "GET",
  "path": "/test/path",
}

Sample POST request:

{
  "body": "{\"value\":\"test\"}",
  "httpMethod": "POST",
  "path": "/test/path
}

See Input format of a Lambda function for proxy integration in AWS docs for more details and attributes.

stawecki avatar Apr 27 '21 16:04 stawecki