Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 1.77 KB

File metadata and controls

29 lines (17 loc) · 1.77 KB

AWS Lamda Functions input/output model:

From: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html function signatures are:

  • async function(event, context) or
  • function (event, context, callback)

Parameters are:

  • event - The invoker passes this information as a JSON-formatted string when it calls Invoke, and the runtime converts it to an object.
  • The second argument is the context object, which contains information about the invocation, function, and execution environment. In the preceding example, the function gets the name of the log stream from the context object and returns it to the invoker.
  • The third argument, callback, is a function that you can call in non-async handlers to send a response. The callback function takes two arguments: an Error and a response. When you call it, Lambda waits for the event loop to be empty and then returns the response or error to the invoker. The response object must be compatible with JSON.stringify.

For asynchronous function handlers, you return a response, error, or promise to the runtime instead of using callback.

Response is object must be compatible with JSON.stringify as JSON is returned

Logging

Logging uses console.log, err

Error handling

https://docs.aws.amazon.com/lambda/latest/dg/nodejs-exceptions.html still returns JSON

Related Links