DynamoDB is an AWS-hosted, serverless, key-value store. It has an (optionally) composite key consisting of a Hash key and a Sort key. The item (record) consists of attributes. These attributes are typed - the basic types that this tutorial will be concerned with are String, Number, Boolean, and List; though, there are other types such as Binary and Map that you might need to use.
Getting Started - Prerequisites
NodeJS - this tutorial is developed with Node 14, though most it should work with minor tweaks on Node 12 or earlier.
AWS CLI (optional) - while you can provide credentials other ways, and check the status of your DynamoDB table through the console, using the AWS CLI is preferred, and this tutorial will prefer it
Postman or Insomnia (optional). Sure, you could just issue cURL commands if you really wanted to, but these make it much easier. People might argue about which is better in terms of features, but they’ll both do the job for the purpose of this tutorial. FWIW, I use Postman at work and Insomnia at home.
DynamoDB Local (optional) - Amazon provides up to 25 GB of DynamoDB storage in its free tier, but you’ll probably end up paying a few pennies for read/write requests. If you don’t want to spend a dime on this tutorial, you can download and run DynamoDB locally. If you do this, you will need to add the
endpointparameter to your DynamoDB instantiation in the below examples. One example of this will be provided, but the other calls will need it too.
For this tutorial, we are going to create the backend of an application that tracks and reports on a user’s music listening history, similar to Last.fm. Our table will contain information on User Listens and Songs, and our API will support the following operations:
Add/Get Song data
Add/Delete User Song Listens
Report user listening data