aws lambda pass in parameters code example
Example: aws lambda function arguments
The runtime passes three arguments to the handler method.
The first argument is the event object, which contains information from the invoker.
The invoker passes this information as a JSON-formatted string when it calls Invoke, and the runtime converts it to an object.
When an AWS service invokes your function, the event structure varies by service.
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.