Skip to main content
Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console. Open IP Lab Portal

Overview

Lab details

  1. This lab walks you through DynamoDB Console and NoSQL Workbench. You will be creating a DynamoDB table and performing CRUD methods using NoSQL Workbench and visualizing the changes in the DynamoDB console. And also, you will be creating a DynamoDB table in the console and insert items and visualize the reflections in the NoSQL Workbench.
  2. Duration: 60 minutes
  3. AWS Region: US East (N. Virginia) us-east-1

Introduction

What is AWS DynamoDB?

Definition
  • DynamoDB is a fast and flexible NoSQL database designed for applications that need consistent, single-digit millisecond latency at any scale.it is a fully managed database and it supports both document and key value data models.
  • It has a very flexible data model. This means that you don’t need to define your database schema upfront. It also has reliable performance.
  • DynamoDB is a good fit for mobile gaming, ad-tech, IoT and many other applications.
DynamoDB Tables
DynamoDB tables consist of:
  • Items (Think of a row of data in a table).
  • Attributes ((Think of a column of data in a table).
  • Supports key-value and document data structures.
  • Key= the name of the data. Value= the data itself.
  • Document can be written in JSON, HTML or XML.
DynamoDB - Primary Keys
  • DynamoDB stores and retrieves data based on a Primary key
  • DynamoDB also uses Partition keys to determine the physical location data is stored.
  • If you are using a partition key as your Primary key, then no items will have the same Partition key.
  • Composite Keys (Partition Key + Sort Key) can be used in Combination.
  • Two items may have the same partition key, but must have a different sort key.
  • All items with the same partition key are stored together and then sorted according to the sort key value.
  • DynamoDB allows you to store multiple items with the same partition keys.
NoSQL Workbench
  • NoSQL is basically a Non-Relational Database, with a lot of other advantages too.
  • NoSQL Workbench is a virtual development as well as a testing environment for developers across the globe.
  • It allows the users to test their data models over a large number of aspects of functionality and also allows them to develop their software, right from the scratch with ease.
  • In simple terms, the NoSQL Workbench is an IDE platform that includes data modeling, data visualization, and operation building.
  • Data Modeling: Workbench enables users with a facility to build new data models right from scratch or by using existing data models.
  • Data Visualization: As the name suggests, it provides the graphical representation of information and data..
  • Operation Building: Workbench is a strong and reliable platform for building applications and also has a great graphical user interface which eventually makes the communication between the database and the user easier.

Architecture diagram

Task details

  1. Sign in to AWS Management Console.
  2. Create a DynamoDB table through the AWS Console.
  3. Connect to DynamoDB using NoSQL Workbench.
  4. Creating items using the console.
  5. Adding new items to the table using NoSQL Workbench.
  6. Deleting an item using NoSQL Workbench.
  7. Updating an item using NoSQL Workbench.
  8. Creating a new table using NoSQL Workbench.
  9. Adding items into the new table.
  10. Commiting the table and its data to Amazon DynamoDB.
  11. Deleting AWS Resources.

Prerequisites

  1. To work with this lab, it is necessary to download the NoSQL Workbench. To download it, go to the Download NoSQL Workbench Page. Based on your OS, select the respective option under Download link. Once downloaded, open the file and install.

Launching the lab environment

  1. To launch the lab environment, Click on the Launch lab button.
  2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
  3. Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time

Lab guide

Lab steps

Task 1: Sign in to AWS Management Console

  1. Click on the Open console button, and you will get redirected to AWS Console in a new browser tab and it will be Logged in Successfully.
  2. On the AWS Console, in the search bar search for IAM and click on it.
  3. Then Click on IAM Users and select TerraformUser-XXXXX
  4. Click on Create Access Key.
  5. Choose Other, Click on Next and click on Create Access Key.
  6. Your Access and Secret key will get Created. Make a note of it for later use.

Task 2: Create a DynamoDB table through the AWS Console

In this task, you will create a DynamoDB table that is used to add items and visualize the data in the NoSQL Workbench.
  1. Make sure you are in the N.Virginia Region.
  2. Navigate to DynamoDB by clicking on the Services menu at the top and selecting DynamoDB under the Database section.
  3. Click on Create Table on the right side.
  4. Table details:
    • Table name : Enter Student_Info
    • Partition key : Enter StudentId
    • Sort Key : Enter StudentName
  5. Leave everything as default and click on Create table button.

Task 3: Connect to DynamoDB using NoSQL Workbench

In this task, you will configure files and pass access credentials to connect to DynamoDB using NoSQL Workbench and view the DynamoDB table after successful connection. And the credentials you are going to use for making a connection are the Access Key ID and Secret Access Key present on the left side of the lab interface under IAM username and Password.
  1. Open the NoSQL Workbench you have downloaded and installed during the prerequisites step.
  2. Click on the Launch button next to Amazon DynamoDB.
  1. In the left side panel, click on Operation builder and click on Add connection on the right side.
  1. Now we need to configure two files in our local PC to successfully connect to our DynamoDB using NoSQL Workbench.
  • For Windows Users:
  • Go to the destination %USERPROFILE%\\.aws in your local Pc.
  • You will be able to find config and credentials files, which we need to edit using notepad.
  1. Open the config file using notepad and replace the existing content with the one given below.
  1. Save the file using Ctrl+S.
  2. Now open the credentials file using notepad and replace the default aws_access_key_id and aws_secret_access_key with the Access Key ID and Secret Access Key created earlier.
  3. The file after replacing your credentials looks something like this. (I have masked my secret access key as a security protocol)
  1. Save the file using Ctrl+S.
  • For Mac and Linux Users:
  1. Copy and paste your scret key and access key from the lab document
  2. Save the file by pressing Esc button, and type :wq [If you are using Vi editor]
  3. Open your Mac Terminal or Linux Command Line.
  4. You can either use Vi editor or nano to edit the config and credentials files mentioned in the above steps.
  • Enter in your mac terminal.
nano ~/.aws/config
  1. Now paste the content which is tabulated in the Step-7 inside this ~/.aws/config file.
  • Press Ctrl+X and Press Enter to save the file.
  • Now enter
nano ~/.aws/credentials
  1. Now replace the default aws_access_key_id and aws_secret_access_key with the Access Key ID and Secret Access Key present on the right side of the lab interface under IAM username and Password. [Refer Step 9&10 to understand]
  • Press Ctrl+X and Press Enter to save the file.
  1. Now get back to the NoSQL Workbench and fill the following details:
  • Connection name : Enter Connection 3 ( You can give any name of your choice)
  • Default AWS Region : Select us-east-1
  • Access Key ID : Paste your Access Key ID of the lab. (The same way you did in the Step 9)
  • Secret access key : Paste your Secret Access Key of the lab. (The same way you did in the Step 9)
  • Persist connection : Check the box
  • Click on the Connect button.
  1. In the next screen, click on Open under your respective connection.
  1. Now you will be able to see the table(Student_Info) we have created using AWS Console here in NoSQL Workbench.

Task 4: Creating items using the console

In this task, you will create a few items in the DynamoDB table through the console and try to see these items in the NoSQL Workbench.
  1. Make sure you are in the N.Virginia Region.
  2. Navigate to DynamoDB by clicking on the Services menu at the top and selecting DynamoDB under the Database section.
  3. On the left side panel, click on Explore Items and select your table i.e Student_Info
  4. Click on the Create item button on the right side.
  5. Attributes:
    • StudentId : Enter 1
    • StudentName : Enter Jay
    • Click on Add new attribute and select String
    • Give Attribute name as FavoriteSport and Value as Cricket
    • Click on Create item button.
  1. Similarly create the following items shown below with their respective Attribute names and Values by following the above steps.
  1. Now you will be able to see three items returned in the Student_Info table in the console.
  2. Now open the NoSQL Workbench window from your taskbar to see if these newly created items in the console are present in the NoSQL Workbench.
  3. Go to Operation builder > Tables > Student_Info and click on the Scan button on the right side.
  4. Now you will be able to see three items in the Student_info table in the Workbench.

Task 5: Adding new items to the table using NoSQL Workbench

In this task, you will add two new items to the existing table from NoSQL Workbench and see the reflections in the DynamoDB console.
  1. Now on the top right corner click on Action operation and click on Create Item.
  2. Build Operations:
    • Table : Select Student_Info
    • Partition key : Enter 4
    • Sort key : Enter Harsh
    • Click on + sign next to Other attributes
    • Attribute name : Enter FavoriteSport
    • Attribute type : Select String from the drop down menu
    • Attribute value : Enter Volleyball
  3. Now click on the Save operation button.
  4. Scroll down a little and give the Name under Save operation as test1 and click on the Save button.
  5. You can give a name of your choice for Save operation as well, it does not matter.
  6. Now click on the Run button which is next to Save operation.
  7. Expand the table by clicking on it to see the result.
  8. Click on the Scan button on the right side if you do not see any item.
  9. Similarly add one more item from the NoSQL Workbench using Create Item operation:
    • StudentId as 5
    • StudentName as Virat
    • FavoriteSport as Rugby
  10. The table looks something like this in the Workbench. Click on the Scan button on the right side if you do not see any items.
  11. Now head back to the DynamoDB console and refresh the page to see these newly added items there.

Task 6: Deleting an item using NoSQL Workbench

In this task, you will delete an item from the Workbench and see the reflections in the DynamoDB console.
  1. Now get back to the NoSQL Workbench.
  2. Scroll to the top and click on Expand Action operation and choose Delete item.
  3. Build Operations:
    • Data plane operations : Select DeleteItem from the drop down menu
    • Table : Select Student_Info
    • Partition key : Enter 1
    • Sort key : Enter Jay
  4. Now click on the Save operation button.
  5. One pop-up will appear to confirm to deletion.
  6. Click on the table on the left side to expand it and see the result. Click on the Scan button on the right side if you do not see the result.
  1. Now head back to the DynamoDB console and refresh the page to see if the item has been deleted here as well or not.

Task 7: Updating an item using NoSQL Workbench

In this task, you will update an existing item through NoSQL Workbench and see if it is reflected in the DynamoDB console as well.
  1. Now get back to the NoSQL Workbench.
  2. Click on the StudentId where it is 2
  3. Build Operations:
    • Update expression : Select Set from the drop down menu.
    • Click on + sign next to it.
    • Set:
      • Attribute name : Enter FavoriteSport
      • Operators : Select = sign from the drop down menu.
      • Attribute type : Select String from the drop down menu.
      • Value : Enter Football in the <empty> box.
  4. Now click on the Save operation button.
  5. Scroll down a little and give the name under Save operation as test3 and click on Save button.
  6. Now click on the Run button which is next to Clear form.
  7. Click on the table on the left side to expand it and see the result. Click on the Scan button on the right side if you do not see the update
  1. Now head back to the DynamoDB console and refresh the page to see if the item has been updated here as well or not.

Task 8: Creating a new table using NoSQL Workbench

In this task, you will create a new table with Movies as its name using NoSQL Workbench to add a few items and see if it has been updated in the dynamoDB console as well.
  1. Now get back to the NoSQL Workbench.
  2. In the NoSQL workbench, click on the Data modeler below the Amazon DynamoDB section.
  3. Click on + sign below Data model to create a new data model.
  4. Create data model for Amazon DynamoDB select Make Model from scratch:
    • Name : Enter Movies Name
    • Author : Enter <Your Name>
  5. Click on the Create button.
  6. Click on + sign next to Tables which is below Data model to create a new table (or) click on + Create new table option present on the right side.
  7. Add DynamoDB table:
    • Table name : Enter Movies
    • Partition key : Enter Id and select Number from the drop down menu.
    • Add sort key : Check
    • Sort key : Enter Name and select String from the drop down menu.
    • Other attributes : Click on + Add other attribute
  • Attribute name : Enter FavoriteMovie and select String from the drop down menu.
  1. Leave the other settings as default and click on Add table definition button.
  1. The next screen you see will be something like this.

Task 9: Adding items into the new table

In this task, you will add a few new items into the newly created Movies table through NoSQL Workbench.
  1. Click on the Visualizer option on the left side panel .
  2. Click on the Update button next to the Movies table and click on Actions from the drop down choose Edit data.
  1. Adding data:
  • Under Id : Enter 1
  • Under Name : Enter Sherley
  • Under FavoriteMovie : Enter Harry Potter
  1. Click on + Add new row to add two other items as shown below. And once done, click on Save Changes button.
  1. Now click on Aggregate view to see data stored in the table in aggregated form.

Task 10: Commiting the table and its data to Amazon DynamoDB

In this task, you will commit the table and its items to the DynamoDB database in the console from NoSQL Workbench and see if it has been added to the DynamoDB console.
  1. Click on Commit to Amazon DynamoDB button under Aggregate view.
  1. In the next screen, select your connection name from the Saved connections drop down menu. [ In my case - Connection 3 ]
  2. Now click on the Commit button. It will take a few seconds to process.
  1. Now in the next screen, under Active connections, click on Open under your connection name. [ In my case - Connection 3 ]
  1. Now you will be able to find the Movies table under Tables section just above your Student_Info table.
  1. Now click on the Movies table to expand it and see the items you have created earlier inside this table.
  1. Now head back to the DynamoDB console, refresh the page and click on Tables on the left side panel.
  2. You will see the Movies table present here in the DynamoDB console.
  1. Click on the Items section beneath the Tables on the left side panel and select Movies table.
  2. You will be able to find the three items you have created through NoSQL Workbench, here in the console.
  1. You can play around by updating and deleting items in the new table i.e Movies.

Do you know?

NoSQL Workbench allows multiple team members to collaborate on the data modeling process. You can share your data models with others, making it easier to work together and gather feedback. It is user for Collaboration and sharing.

Task 11: Validation Test

  1. Once the lab steps are completed, please click on the Validate button on the left side panel.
  2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
  3. Sample output :

Task 11: Delete AWS Resources

Deleting DyanamoDB Tables
  1. Navigate to DynamoDB by clicking on the Services menu at the top and selecting DynamoDB under the Database section.
  2. Click on Tables on the left side panel.
  3. Select the tables you have created and click on the Delete button on the right side.
  1. In the next screen,
  • Delete all CloudWatch alarms for the tables shown : Check
  • Create backups of all tables shown before deleting them : Uncheck
  • Enter delete in the confirmation box.
  1. Click on the Delete tables button to delete the tables.

Completion and conclusion

  1. You have successfully created a DynamoDB table through the DynamoDB console.
  2. You have successfully connected to DynamoDB using NoSQL Workbench.
  3. You have successfully performed CRUD methods through NoSQL Workbench and seen the reflections in the DynamoDB console.
  4. You have successfully created a table through NoSQL Workbench and committed to Amazon DynamoDB.

End lab

  1. Sign out of the AWS Account.
  2. You have successfully completed the lab.
  3. Once you have completed the steps, click on End lab button in the IP Lab Portal.

What gets checked

When you press Check my work, the platform verifies each of these:
  • Create Amazon DynamoDB Table — Check whether a DynamoDB Table is created or not.
  • Create Items in DynamoDB Table — Check whether items in the DynamoDB table are created or not.