5. Hello World   Just like almost every other programming tutorial, I will begin our exploration of Lambda with the simplest function: one that only echos back “Hello World.” Even though Lambda allows you to edit code in-line directly from the Lambda console, only the simplest of functions can use this. The rest, any functions with more than one file or dependencies, will need to be zipped and uploaded. Since almost every function you write will require this, we’ll use this format for creating our “Hello World” function.   Create a new file in your editor of choice named “index.js”. Inside this file, add the following contents:   exports.handler = function(event, context) {    context.succeed("Hello world"); };   That’s it! This is the simplest Lambda function you can create. While we’re here, let’s talk about each of its parts:   ●       exports.handler ○       This is the exported method that will be called by Lambda when the function executes. You can export multiple methods, but you will need to select one when creating your Lambda function in the console. While you don’t have to call your exported method “handler,” it’s the default used by Lambda and I recommend using it. ●       (event, context) ○       Your exported method must take these two arguments. The “event” is the object that contains details about the executing event. For example, when S3 triggers a Lambda function, the event contains information about the bucket and key. When the API Gateway triggers a Lambda function, the event contains details about the HTTP method, user input, and other web-based session information. The “context” object contains internal information about the function itself, as well as methods for ending the function (both successfully and unsuccessfully). We’ll explore these objects in-depth shortly. ●       context.succeed ○       The “succeed” method of the context object allows the function author to tell Lambda that the function has completed its execution successfully. The argument passed to “succeed” (“Hello World” in this case) will be returned to the invoker.   Uploading the Function   Despite the fact that our function only contains a single file, create a ZIP file to wrap it. The name of the ZIP file doesn’t matter.   Log into the Lambda console and click “Create a Lambda function.” AWS provides a number of Lambda blueprints, but since we already have a ZIP, just click “Skip.” Give your function a useful name and description, and select “Node.js” as the runtime.   The next page allows you to either enter your code inline, upload it via a ZIP, or enter an S3 URL path to a ZIP hosted on S3. Select the second option and locate the ZIP you created.   Under the “Lambda function handler and role” section, you will need to define which file and exported method should be used to process events. If you followed the steps above, you can leave the default “index.handler.” If you’ve chosen a different name, make sure that it follows the guidelines above (takes “event” and “context” as arguments, and ends with “context.succeed”).   Next, you’ll need to select a role for the execution of your function. We’ll discuss roles in more depth soon, but for now, understand that they behave just like EC2 IAM roles and allow your Lambda function to access resources within your account. At a minimum, your function will need permission to log its events to CloudWatch. AWS has simplified the creation of roles by allowing you to select pre-defined roles from a drop-down list. For the “Hello World” function, you can select the basic execution role. A popup will prompt you to create the role within IAM.   The “Advanced settings” allow you to define the memory and time allocated to your function. In our case, echoing “Hello World” should only require the minimum memory and time.     You can review and then create your function on the next page. Once complete, you’ll be able to test it. To do this, click on your function from the main overview page and then choose “Actions” > “Configure sample event.” You can just use an empty event object of “{}” because the “Hello World” function does not require any event properties. Click “Submit” and you should see the results of your function: “Hello World.” You’ll also see a lot of extra information like logs, execution time, and memory consumption.     You’ll also notice that a log group and stream were created within CloudWatch. Every Lambda execution will log its events (and any in-app console.log statements) to the CloudWatch log group.