Building a Serverless Application Using Step Functions, API Gateway, Lambda, and S3 in AWS

1.75 hours
  • 4 Learning Objectives

About this Hands-on Lab

In this AWS hands-on lab, we will create a fully working serverless reminder application using S3, Lambda, API Gateway, Step Functions, Simple Email Service, and Simple Notification Service.

While the lab does use Python and JavaScript, you don’t need to be able to code to understand and implement the solution. By the end of the lab, you will feel more comfortable architecting and implementing serverless solutions within AWS.

Let’s get started!

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the Lambda Functions

You will need to create three Lambda functions for use in the Step Function using the resouces provided in the GitHub Repo.

  • Create an email reminder function called email using the contents of email_reminder.py. This function will require the use of a Simple Email Service (SES) verified email, so you will need to create and verify a new email identity in SES.
  • Create an SMS reminder function called sms using the contents of sms_reminder.py.
  • Create a function called api_handler using the contents of api_handler.py. Please note that this function will require a Step Function ARN which will be created in the next objective.

For all functions, you will need to utilize Python 3.8 and the LambdaRuntimeRole, which has been created with this lab environment.

Create a Step Function State Machine

Create a Step Function State Machine using the option to Write your workflow in code, and utilize the code provided in the step-functions-template.json file. This code is partially completed and will need to be updated to include your Email Reminder ARN and SMS Reminder ARN from the Lambda functions you created in the previous objective. Once the Step Function has been deployed, update your api_handler Lambda function to include the ARN for your Step Function.

Create the API Gateway

Create an API Gateway using REST API with the REST protocol. You will need to create a New API called reminders and ensure that you Enable API Gateway CORS. Once the API has been created, you will need to create a POST method for /reminders in the us-east-1 region that uses the api_hanlder function that was created earlier and deploy the API Gateway as a New Stage called prod.

Create and Test the Static S3 Website

Download a local copy of the static_website folder with its contents from the GitHub repo and modify the formlogic.js file to include the Invoke URL from your API Gateway. Make sure to keep /reminders at the end of the string. Once the file has been modified, create a web enabled S3 bucket with static website hosting enabled and upload the static_website folder to your S3 bucket. Use the Bucket website endpoint to access and test the functionality of the website by sending an email reminder to your SES verified email and verify you receive the message. Observe the visual workflow of the event in Graph Inspector for MyStateMachine in AWS Step Functions.

Additional Resources

Log in to the live AWS environment using the credentials provided. Make sure you're in the N. Virginia (us-east-1) region throughout the lab.

All of the resources needed to complete this lab are available from this GitHub repo.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?