Module 1: Application Background
To get started, you will explore the tutorial prerequisites.
Imagine that you are building an online bookstore application. Your bookstore has a large inventory of books that are stored in your warehouse to be sold to customers. The application must show users the books that are available for sale as well as some basic information about the book, such as its author.
The application needs to retrieve a specific book by its title and author so that a user can drill in for more detail when looking at a book. Furthermore, your application should allow users to browse all books in a particular category, such as history or biography, to allow for discoverability of interesting books.
Finally, you may carry different formats of a book, such as hardcover, paperback, or audiobook. Your application should store the formats you have in stock for a book with a mapping to the item number in your inventory system. Your application should allow these formats to be updated over time, as you may add or remove formats for a book.
In the modules in this tutorial, you learn how to model a DynamoDB table to accommodate these application needs.
In order to complete this tutorial, you need an AWS account and access to create AWS Identity and Access Management (IAM), Amazon DynamoDB, and AWS Cloud9 resources in that account. The step-by-step guide in this tutorial explains how to set up all prerequisites.
Create an AWS account
Use a personal account or create a new AWS account for this tutorial rather than using an organization’s account to ensure that you have full access to the necessary services and do not leave behind any resources from the tutorial.
Set up your AWS Cloud9 IDE
AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug code with just a browser. AWS Cloud9 includes a code editor, debugger, and terminal. It also comes prepackaged with essential tools for popular programming languages and the AWS Command Line Interface (CLI) preinstalled so that you don’t have to install files or configure your laptop for this lab. Your AWS Cloud9 environment will have access to the same AWS resources as the user with which you signed in to the AWS Management Console.
To set up your AWS Cloud9 development environment:
- Navigate to the AWS Management Console, choose Services at the top of the page, and then choose Cloud9 under Developer Tools.
- Choose Create environment.
- Type DynamoDB Deep Dive in the Name box. Optionally type a Description.
- Choose Next step.
- Leave the Environment settings at their defaults to create a new t2.micro EC2 instance, which will be hibernated after 30 minutes of inactivity.
- Choose Next step.
- Review the environment name and settings, and choose Create environment. Your environment will be provisioned and prepared after several minutes.
- Once ready, your IDE will open to a welcome screen.
You should now see your AWS Cloud9 environment. There are three areas of the AWS Cloud9 screen to know, as illustrated in the following screenshot:
- File explorer: On the left side of the screen, this shows a list of the files in your directory.
- File editor: On the upper right portion of your screen, this is where you view and edit files that you’ve selected in the file explorer.
- Terminal: On the lower right portion of the screen, this is where you run commands to execute code samples.
Download the supporting code
In these modules, you use Python scripts to interact with the DynamoDB API.
Run the following commands in your AWS Cloud9 terminal to download the scripts and install the application dependencies:
1. Download and unpack the module code by running the following command in the AWS Cloud9 terminal
curl -sL https://s3.amazonaws.com/ddb-deep-dive/dynamodb.tar | tar -xv
2. To install Boto 3, run the following command in the AWS Cloud9 terminal.
sudo pip install boto3
You are now ready to start this tutorial. In the first module you insert items into and retrieve items from your DynamoDB table.