- A Cloud Guru
Orchestrating Lambda Functions Using AWS Step Functions
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.
Table of Contents
Set Up S3
- Create an S3 bucket and, inside the bucket, create two folders to host the files: guru-premium-courses and guru-premium-lessons.
- 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.
What's a lab?
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.