Front and Backend DynamoDB Tables

Overview

Screenshot

Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale and was selected for this applications persistent store database.

In this step, two DynamoDB tables will be created. One table will be used to maintain state for the text bot conversation and the other table will be used for the Frontend UI. A two table design was selected because the guest's phone number will be isolated to the backend table and not be accessed by the frontend UI. The tables are created via CloudFormation and a Custom Resource is set up to pre-populate the DynamoDB tables with sample guests and one real guest.

The Custom Resource creates a lambda function that populates the tables via boto3 commands. In addition to populating the DynamoDB tables, a Rekognition Collection will be created during this step.

Login to the AWS console (Required)

Step1: Get Login credentials

Make sure you have the login credentials that were given out in the beginning of the workshop.

Step2: Login to the AWS Console

Login with the AWS Console Login or use the quick link given in the prerequisites page.

Screenshot

CloudFormation (Required)

Step3: CloudFormation Quick Start

A CloudFormation template is used to set up the infrastructure in this section.

To get started, click on the Launch Stack button in your desired region below. US West (Oregon) is the recommended region for this workshop if at re:Invent.

Important

Ensure that you are consistent with the selected region throughout this workshop. Deployments in multiple regions will lead to AWS services not communicating together.

Region Deploy
US West (Oregon) Deploy in us-west-2
US East (Ohio) - Coming Soon Deploy in us-east-2
US East (N. Virginia) - Coming Soon Deploy in us-east-1
EU (Ireland) - Coming Soon Deploy in eu-west-1

In a new tab you should be redirected to CloudFormations Quick create stack page as shown below.

Screenshot

For Stack name, the default reg-app-dynamodb can be used or customized.

Screenshot

The default for the Parameters section will work as is.

  • Front End Table Name - Name for the DynamoDB front end table that will be created.
  • Back End Table Name - Name for the DynamoDB back end table that will be created.
  • First Name - First name for your first guest. This can be yourself or any name.
  • Last Name - Last name for your first guest. This can be yourself or any name.
  • Phone Number - The phone number that will be used to send and recieve SMS/MMS.
  • Twilio Number - The twilio phone number created in the previos section.

Screenshot

Important

If you do not want to use your own phone number. Please let the workshop owner know before continuing on with this step.

On the next window, scroll to the bottom and under Capabilities check I acknowledge that AWS CloudFormation might create IAM resources. and click Create stack.

Screenshot

The CloudFormation template will take about 2 minutes to create. Ensure that there is a CREATE_COMPLETE for the CloudFormation template before moving on to the next section.

Success

You are now completed with setting up the frontend and backend DynamoDB tables! Sample data was populated in the tables by the use of a CloudFormation Custom Resource. A Rekogntion collection was also created during this step.

DynamoDB (Optional)

This is an optional step to take a look at the DynamDB tables that were created. There is also pre-populated data in the tables that is used as sample data/guests in this workshop.

Step4: Inspect Backend DynamoDB Table

In the services tab, enter DynamoDB.

Screenshot

On the left of the console, click on Tables.

Screenshot

There should be two tables created. If the default names were used in the previous step then you see two tables like below:

Screenshot

Click on the backend table created reg-app-backend and then click on Items.

You can see that you yourself are entered as a guest (if done so during the CloudFormation build). You will also see that there are a couple sample guests in the table. These guests will act as sample data points during your event. Take note that personal phone numbers are stored in the backend table.

Screenshot

Step5: Inspect Frontend DynamoDB Table

Now take a look at the frontend table that was created reg-app-frontend and then click on Items.

Just as in the backend table, there is pre-populated data in the frontend table. These items are what will be used for the public facing event web application. Take a note that phonenumbers are not included in this table. This is to ensure that personal phone numbers are not scraped from the public site and used for unwanted pruposes.

Screenshot

How was this done with CloudFormation

CloudFormation Custom Resource

Success

You can move on to the next step!