In this lab scenario, Alfredo’s Pizza is a global fast-food chain selling delicious pizza. Their website serves thousands of customers each day and processes over 6 million in payments each week. While Alfredo is doing well, he’s not seeing the customers he had hoped for, and relying on expensive always-on servers ends up with resources sitting idle, wasting money. Alfredo wants to migrate his application to a serverless architecture with the hope of saving on operating costs. We’ll help him by showing him how easy Lambda functions can be. In this hands-on lab, you’ll author a Lambda function using the Python programming language in the AWS console. We will also review logs generated by CloudWatch.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Author Lambda Function in Python
In this video we will author a Lambda function in Python. The source code for the Lambda function can be found here.
- Navigate to the Lambda portion of the AWS Console.
- Select Create your Lambda Function from scratch.
- Select the latest Python verson as your runtime.
- Copy the code from the example code provided.
- Save and deploy your function after adding the sample code.
- Create a Test Event and Execute Lambda
In this video we will create a test event for testing your function. The test event for the Lambda function can be found here.
- Select the drop-down next to Test at the top of the Lambda console.
- From the drop-down, select Configure test events.
- Copy and paste the test event from the example JSON provided.
- Select Create.
- Click on the Test button and verify your function succeeds.
- Verify that CloudWatch has Captured Function Logs
In this video, we are going to walk through the process to view the CloudWatch logs for the Lambda function.
- Click the Monitor tab.
- Click View logs in CloudWatch.
- Select the most recent log stream.
- View the outputs in the log.