DevOps Event Driven Architecture — Part 4

Overview 🔍

We've successfully built the pipeline to ingest and count movie likes in Lab 3! Now, in our final lab, we'll close the loop by building the component that reads this data and provides recommendations. We'll create a new Lambda function and API endpoint (GET /recommendations) to query DynamoDB, retrieve the movies with the highest like counts, and return them to the UI.

Purpose 🎯

The purpose of this final lab is to:


  • Build the read path of our application, consuming the aggregated data.
  • Implement a Lambda function (GetRecommendationsLambda) to query/scan DynamoDB for movie like counts.
  • Process and sort the data within the Lambda to identify the top-liked movies.
  • Create a new API Gateway endpoint (GET /recommendations) to expose this data.
  • Integrate this new endpoint into the UI to display the recommendations page.
  • Complete the end-to-end application flow and demonstrate the full system in action.

Lab Environment 🛠️

You'll need the same environment as Lab 3:


  • AWS Account, Terraform CLI, AWS CLI.
  • Code editor and Git.
  • Your local UI project.

What We'll Accomplish ✅

In this lab, you will:


  • Log in using your AWS credentials if necessary.
  • Use Git to pull the latest code from your repository (containing work from Lab 3) G±.
  • Develop the Python code for the GetRecommendationsLambda function to:
    • Perform a Scan operation on the MovieLikesTable.
    • Receive the items (movies and their like counts).
    • Sort the items in descending order based on likeCount.
    • Format the sorted list as a JSON array response.
  • Define the GetRecommendationsLambda function resource in Terraform, including code packaging and IAM role reference.
  • Add the /recommendations resource and GET method to your API Gateway in Terraform, integrating it with GetRecommendationsLambda.
  • Update the API Gateway deployment triggers to include the new endpoint components.
  • Add a Terraform output for the GET /recommendations endpoint URL.
  • Run terraform apply to deploy the new Lambda function and API Gateway configuration.
  • Retrieve the GET /recommendations API endpoint URL from Terraform outputs.
  • Final Integration Step: Update your UI application's configuration to fetch data from this new endpoint.
  • Test the entire end-to-end system: Like movies, then view the recommendations page to see the sorted list.
  • Commit and push the final project code to GitHub.

Completing the Circle: From Event to Insight 💡

This lab demonstrates how the data generated and processed asynchronously through our event-driven pipeline can be queried and presented back to the user. While the ingestion path was decoupled and asynchronous, the read path (GET /recommendations) follows a more traditional synchronous request/response pattern, directly querying the aggregated state stored in DynamoDB. This combination of patterns is common in real-world applications.


Let's build the final piece of our event-driven system!

Difficulty
Beginner
Time to Complete
60 minutes
Price
Premium
Environments You will be given access to live environments below as part of this lab
AWS AWS
Ubuntu Ubuntu
About Author

Review Project Content id: 67f56d92cb59420c61f8ec02 By Starting this lab you agree to Prepare.Sh Terms of Service (TOS)