Orchestrating Lambda Functions Using AWS Step Functions

1 hour
  • 4 Learning Objectives

About this Hands-on Lab

AWS Lambda functions can be integrated within Step Functions state machines to orchestrate workflow and create conditional logic. In this AWS hands-on lab, you’ll be building two Lambda functions and orchestrating the functions using Step Functions. Step Functions use numerical scores provided by students to determine the appropriate rewards to provide to the students by invoking the respective Lambda function. The orchestration of the workflow will rely on Step Functions calling the appropriate Lambda function depending on the inputted score.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Set Up S3
  1. Create an S3 bucket and, inside the bucket, create two folders to host the files: guru-premium-courses and guru-premium-lessons.
  2. Download the CSV files from this lab’s GitHub repository, and upload them to the respective folders created in the previous step.
Create the Lambda Functions

Create two Lambda functions as follows:

First Lambda Function

The function should return a response object consisting of the following:

  • A message congratulating the user on the high score; you can use the message below:

"Well done. This was a hard quiz, and you nailed it! Here are your premium courses!"

  • A list of the premium courses that are retrieved from the respective S3 bucket.

Second Lambda Function

The function should return premium lessons after fetching them from the respective S3 bucket.

  • A message motivating the user to keep on practicing; you can use the message below:

"You didn’t pass. Don’t worry! Practice makes perfect. Here are premium lessons to keep you going!"

  • A list of premium lessons that are retrieved from the respective S3 bucket.

Note: Configure the IAM role of the functions to grant it access to S3.

Set Up IAM Roles

Create a new IAM role that will enable the Step Functions to trigger the Lambda functions.

Set Up AWS Step Functions

Create and test a new state machine that will take in a score from users. The orchestration should follow the logic below:

  • If the inputted score is less than 75, the state machine should trigger the Lambda function that will return the premium lessons.
  • If the inputted score is more than 74, the state machine should trigger the Lambda function that will return the premium courses.
  • Afterwards, the machine should terminate.

Additional Resources

Scenario

You've been tasked with creating a rewards workflow logic. Our logic needs to reward students with higher scores by granting them access to premium courses. For students with lower scores, the logic needs to grant the students access to premium lessons instead of full courses.

Before you start the lab, get the necessary CSV files from this lab's GitHub repository.

Make sure you are in the us-east-1 Region throughout this lab.

Additional Resources

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?