Building an API with AWS SAM CLI and DynamoDB Tables

Learn how to build an API in TypeScript using AWS SAM CLI and DynamoDB tables.

Building an API

Now that we have a working AWS SAM CLI environment configured, we can build an API.

The API that we will build in this chapter will be used to support the three existing applications that we have been building throughout this course in Angular, React, and Vue.

  • Our Angular application revolved around a user logging into an application. This means that we will need to store and retrieve user details from a database.

  • The React application that we built showed a list of products for sale, and when a particular product was chosen, it would show the details of the product. To support this, we will need to store and then retrieve our products from a database and allow for the generation of a list of available products. We also included the option of selecting how many of these products to add to a shopping cart.

  • The Vue application that we built was responsible for displaying a user’s current shopping cart and allowed for updating as well as deleting the products in the cart. In order to support this functionality in our API, we will need a mechanism to store and retrieve a user’s shopping cart information, including the products they have ordered and the amount of each product they have selected.

DynamoDB tables

To support the functionality that our applications require, we will need three DynamoDB database tables, as shown in the following diagram:

Get hands-on with 1200+ tech skills courses.