Instructor: In order to configure a lambda function, we need to create a serverless.yml file. In here, we define multiple fields. First, we define a service name, myApp, then set the provider and the runtime. Next up, we allow a functions section, and add a Hello World function.
The handler is referring to the file handler, which should export a function, run. Since we don't have that file yet, we create handler.js. We export the function run, accepting three parameters, event, context, and callback.
The event is an object and contains all the necessary request data. Context is an object as well. It contains a couple of AWS-specific values, like AWS request ID, log group name, and so on. Callback is a function and should be invoked with either an error response as the first argument or a valid response as the second argument.
Now we have all we need to deploy our first function. We can run SLS deploy from our terminal. This will package up to the function to a ZIP file, and then deploy the whole thing with a cloud formation stack.
Once deployed, you can invoke the lambda function directly using SLS invoke. As expected, it returns Hello World. One cool feature about invoke is that you can also log out a debug statement. Let's try this by adding a console log