Building a Microservice Application and DynamoDB Data Model

2 hours
  • 6 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we will be presented with a web front end that is ready to be connected to a data system back end. We will analyze the provided dataset, create a data model, create a DynamoDB table, and edit two Lambda functions to load data into the table we will create, and connect that table to an API to provide data to the website.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Examine Source Data and Formulate Data Model

Examine the source data (linked in the lab instructions) and formulate a data model that will allow storing and accessing this data from a single DynamoDB table.

Create a DynamoDB Table

Considering the data model from the last task, create a DynamoDB table to manifest the features of your data model. The table must be named collectors.

Add Data Transformations/Mutations to `collectors_load` Lambda Function

Add any necessary data transformations from your data model created in task one to the collectors_load function.

(The solution code is linked on the lab page.)

Run `collectors_load` Function

Use an empty test event to run the collectors_load function to load data into the collectors DynamoDB table.

Implement Queries in `collectors_primary` Lambda Function

Implement queries to satisfy the required access patterns in the collectors_primary Lambda function.

(The solution code is linked on the lab page.)

Validate API Responses

Using the provided website and API Gateway endpoint, verify all requested access patterns return the correct data.

Additional Resources

We are stepping into the role of a data architect working for a social media startup who is creating a network for people to share their various collections. The front-end web development team has provided the following data:

CSV:

JSON (DynamoDB Batch Write formatted):

They have requested that we create a data model to structure this data, as well as a DynamoDB table utilizing the data model to house the data.

They've also provided a function to load this data into the table which must be named collectors, additionally a skeletal Lambda function that is pre-configured to respond to requests from the API Gateway which will need to have the appropriate queries to fullfill the following access requirements added to it, as well as any necessary data management to return the data in the format that is expected by the web front end application.

Expected data for full profile load in the web front-end application:

{
    "picture": "URL",
    "fullName": "John Hanna",
    "location": "Washington, USA",
    "icons": ["comics", "movies"],
    "collections": {"john_comics": {"icon": "comics", "items": 
        [
            {
                "author": "Katsuhiro Otomo",
                "collection_id": "john_comics",
                "image": "https://dynamodblabs.s3.amazonaws.com/collectors/images/john/comics/Akiravol1.jpg",
                "isbn": "1935429000",
                "order": "1",
                "pages": "352",
                "pencil": "Katsuhiro Otomo",
                "published date": "October 31 2009",
                "publisher": "Kodansha Comics",
                "series": "Akira",
                "thumb": "https://dynamodblabs.s3.amazonaws.com/collectors/images/john/comics/thumbs/Akiravol1.jpg",
                "title": "Akira Vol 1",
                "type": "item"
            },
            {}
        ]
    }},
    "recentActivity": [],
    "lastAddition": {},
    "friends": []
}

From the above, it should be possible to access each section of the page data independently, including profile, collections, recent activity, latest addition, and friends.

The code used in the solution videos for this lab can be found here.

Note: The data model presented in the solution videos is intentionally suboptimal.

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?