In this hands-on lab scenario, you’ll write a Node.js Lambda function that checks a URL (like _www.amazon.com_) and returns the status code that signifies if the website is up and running or down. During this lab, you’ll have the opportunity to explore the Lambda console, function code, execution roles, test events, and execution results. AWS Lambda allows you to write concise functions and only worry about your code. Since Lambda is serverless, AWS manages the underlying infrastructure for you.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Author Node.js Lambda Function in AWS Console
- Navigate to Lambda.
- Click Create function.
- Select Author from scratch.
- Name your function.
- Select Node.js as the runtime.
- Select Create a new role with basic Lambda permissions.
- Click Create function.
- In a new browser tab, navigate to the lab GitHub repository link provided on the lab page.
- Copy the
index.js
code, and replace the Lambda function code with it. - Deploy your function.
- Test Function Using a Test Event
- Click the Test button on the Lambda function dashboard.
- Leave the default values, and click Create.
- Click the Test button.
- Review the output response.
- View Lambda’s CloudWatch Logs
- Click on the Monitoring tab.
- Click View logs in CloudWatch.
- Click on the most recent log stream in the Log streams section.
- Notice the billed duration.