In this hands-on lab, we are going to build and troubleshoot a serverless web application using the following technologies:
* DynamoDB
* Lambda
* API Gateway
* S3
* X-Ray
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create a DynamoDB Table
- Create the DynamoDB table and populate it using the file named
items.json
. All files required for this hands-on lab are located in the folder namedBuilding_and_Troubleshooting_a_Serverless_Web_Application
that you will find in the following GitHub repository.
- Create the DynamoDB table and populate it using the file named
- Create a Lambda Function with an API Gateway Endpoint
- Create a Lambda function using
lambda_function.py
. - Test the function to see if it works.
- Diagnose and fix an error with the function configuration.
- Add an API gateway endpoint to your function; make sure you select a REST API.
- Test that the API gateway can be used to invoke your Lambda function.
- Create a Lambda function using
- Create an S3 Bucket and Upload the Website Files
- Modify
index.html
to add the invoke URL of your API Gateway endpoint. - Create an S3 bucket with public access enabled.
- Upload the following website files to your bucket. Make sure they have public-read enabled:
index.html
,error.html
,cookie.html
- Configure S3 static website hosting on your S3 bucket.
- Check you can access everything from the S3 website-hosting URL.
- Modify
- Configure X-Ray
- Enable tracing from within the Lambda function.
- Enable the API gateway endpoint to send traces.
- Add the Lambda Layer to your function using the file named
layer.zip
. - Update your Lambda function code to import the X-Ray SDK to your function using the snippet provided named
lambda_function_xray.py
. - Test the function to see if it works.
- Diagnose and fix an error with the function configuration.
- Review The X-Ray Service Map
- Generate some traffic to your website.
- Review the X-Ray service map and traces.
- Break the application and see the results displayed in X-Ray.