hands-on lab

Serverless Web Development with Python for AWS

Difficulty: Intermediate
Duration: Up to 2 hours
Students: 1,663
Rating: 4.3/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

Serverless architectures let cloud providers handle the burden of managing servers and scaling to meet demand. Costs can also be reduced because you only pay for the compute resources needed to handle requests instead of paying for idle servers waiting for requests to come in. In this lab you will practice serverless web development with Python for AWS by testing and deploying a to-do list application that uses:

  • AWS Serverless Application Model (SAM) to package and deploy the API code as Lambda functions behind an API Gateway
  • Cognito user pools to handle user registration and sign in
  • DynamoDB for persisting each users to-do list

Lab Objectives

Upon completion of this lab you will be able to:

  • Test, package, and deploy serverless Python applications following the AWS Serverless Application Model (SAM)
  • Configure an Amazon Cognito user pool as an API Gateway authorizer
  • Synchronize a local folder with Amazon S3 to publish a website

Lab Prerequisites

You should be familiar with:

  • Working with Linux on the command-line
  • Basic concepts of Amazon S3, Cognito, API Gateway, Lambda, DynamoDB, and AWS command-line interface (CLI)
  • Experience developing in Python is beneficial but not required
  • The Build AWS Serverless Web Applications With Python Course walks through a similar development scenario as this Lab and can be beneficial to watch

Lab Environment

Before completing the lab instructions, the environment will look as follows:

After completing the lab instructions, the environment should look similar to:

Updates

October 25th, 2023 - Updated the instructions and screenshots to reflect the latest UI

June 14th, 2023 - Resolved permissions issue

June 5th, 2023 - Resolved an issue that caused the lab to fail to setup on rare occasions

January 30th, 2023 - Updated the instructions and screenshots to reflect the latest UI

August 12th, 2022 - Upgraded to Python3.9 lambda functions

May 6th, 2022 - Resolved Python Virtual Environment issue

April 6th, 2022 - Updated screenshots and added instructions for clarity

December 13th, 2021 - Updated the student's permissions to create the S3 bucket after recent changes to required IAM permissions

October 21st, 2021 - Updated the application's first sign-in alert message

October 8th, 2021 - Updated EC2 User Data to address virtual environment issue

August 30th, 2021 - Updated lab to reflect the latest console experience

March 27th, 2020 - Inserted validation checks through the lab steps

February 18th, 2020 - Updated lab code repository to resolve an issue causing the source code files to not load onto the EC2 instance

January 3rd, 2020 - Updated lab startup procedure to resolve an issue causing the EC2 instance's Python virtual environment to not be created

January 10th, 2019 - Added a validation Lab Step to check the work you perform in the Lab

September 24th, 2018: Updated the Lab to workaround an issue with the moto AWS mock library now supporting newer versions of boto3

Covered topics

Lab steps

Logging In to the Amazon Web Services Console
Creating a DynamoDB Table for the Serverless Application
Creating a Cognito User Pool for the Serverless Application
Creating an S3 Bucket for the Web Front-End Assets
Connecting to an EC2 Instance Using Amazon EC2 Instance Connect
Testing the Serverless API Code
Fixing the Python Serverless API Code
Deploying the Serverless API Code
Modifying the API Gateway Configuration
Testing the Front-End Website
Deploying the Front-End Website to S3