arrow_back

AWS Technical Essentials – Lab 5: Create an DynamoDB table

AWS Technical Essentials – Lab 5: Create an DynamoDB table

2 hours Free

© 2022 Amazon Web Services, Inc. or its affiliates. All rights reserved. This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon Web Services, Inc. Commercial copying, lending, or selling is prohibited. All trademarks are the property of their owners.

Note: Do not include any personal, identifying, or confidential information into the lab environment. Information entered may be visible to others.

Corrections, feedback, or other questions? Contact us at AWS Training and Certification.

Objectives

After completing this lab, you will be able to:

  • Create an Amazon DynamoDB table
  • Use a web application to add DynamoDB table items
  • Use the AWS Management Console to manage DynamoDB table items
  • Use the console to create DynamoDB table items

Prerequisites

This lab requires:

  • Notebook computer with Wi-Fi and Microsoft Windows, macOS, or Linux (Ubuntu, SuSE, or Red Hat)
  • Administrator access (Microsoft Windows users)
  • Internet browser, such as Chrome, Firefox, or Internet Explorer 9 or later
  • SSH (Secure Shell) client, such as PuTTY

Note: Tablet devices cannot access the lab environment, although they can display student guides.

Duration

This lab requires 40 minutes to complete.

Scenario

In this lab, you will create a DynamoDB table called Employees. Then, you will add items to the DynamoDB table using both a web application's user interface and the AWS Management Console.

Start lab

  1. To launch the lab, at the top of the page, choos Start Lab.

This starts the process of provisioning the lab resources. An estimated amount of time to provision the lab resources is displayed. You must wait for the resources to be provisioned before continuing.

If you are prompted for a token, use the one distributed to you (or credits you have purchased).

  1. To open the lab, choose Open Console.

The AWS Management Console sign-in page opens in a new web browser tab.

  1. On the Sign in as IAM user page:
  • For IAM user name, enter .
  • For Password, copy and paste the Password value listed to the left of these instructions.
  • Choose Sign in.

Do not change the Region unless instructed.

Common sign-in errors

Error: You must first sign out

If you see the message, You must first log out before logging into a different AWS account:

  • Choose the click here link.
  • Close your Amazon Web Services Sign In web browser tab and return to your initial lab page.
  • Choose Open Console again.

Error: Choosing Start Lab has no effect

In some cases, certain pop-up or script blocker web browser extensions might prevent the Start Lab button from working as intended. If you experience an issue starting the lab:

  • Add the lab domain name to your pop-up or script blocker's allow list or turn it off.
  • Refresh the page and try again.

Task 1: Create an Amazon DynamoDB Table

Infrastructure

In this lab, you will create a DynamoDB table, and then use both the Employee Directory web application and the AWS Management Console to test it. Some resources required by the web application are provisioned for you. The resources include a VPC with a public subnet in an Availability Zone, with a route table for the subnet, as shown. Additionally, an Amazon Simple Storage Service (Amazon S3) bucket is provisioned to store the employee images. Currently, the web application runs in .

Task 1

To access the web application, do the following:

  1. From the left pane, copy .
  2. In a new browser tab, paste the URL you copied in the previous step. You should see the application, as shown (you might need to wait a few minutes before the web application becomes available).

Task 1

A warning message states the following:

DynamoDB: 'Employees' table not found.

To fix this, you must create a DynamoDB table called Employees.

  1. In the AWS Management Console, on the Services menu, locate the Database section, and choose DynamoDB. Alternatively, you can type the service name in the Search box to access it.

This lab uses the new console for Amazon DynamoDB. If you are using the previous console, you will see a screen similar to:

Older Dynamo DB UI

You might get the following message at the top or the UI:

The preview of the new DynamoDB console is now available
We are redesigning the DynamoDB console. The preview of the new console is a work in progress, but we encourage you to try it and let us know what you think.

The new DynamoDB console looks like the following:

Dynamo DB new features

  1. If your console does not look like the image above, follow these steps:
  • To enable the preview of the newest DynamoDB UI, locate the last option in the left navigation pane of your console, and choose Switch to the new console experience.
  • You should now see the new UI and might get some informational messages at the top. You can close all of those messages and proceed to the next step.
  1. Choose Create table, and then configure the following fields (you might need to scroll down until you see the Create a table section on the right):

Important! Do not modify any other fields.

  • Table name: , use the the same capitalization shown.
  • Partition key: , select String .
  1. Choose Create table.

The table creation might take a few minutes. Wait until the table is successfully created before continuing.

Task 2: Test the Web Application and Add Items

  1. In your browser, go to the tab where you accessed the web application, and refresh the page.

Note: If you closed the browser tab, open a new one. From the left pane, copy , and paste the URL into the address bar. You should see the application, as shown.

Task 1

You can see the web application no longer displays the warning message regarding the DynamoDB Employees table not being found.

  1. In the Employee Directory application, locate the Administration section in the left pane, and choose Configuration.

You will see the Employee Directory application has access to the following:

  • DynamoDB, which is indicated by the DynamoDB Enabled option's Value of

  • S3 bucket to store the employee images, which is indicated by the S3 Access Enabled option's Value of

  1. In the Employee Directory application, locate the Employees section in the left pane, and choose Management.

  2. Using the Actions dropdown, choose New Employee.

  3. In the Employee details form, fill in the , , and fields.

  4. To provide an employee photo, you can use the URL in the left pane to download images, and then upload them. Use the following steps to access the sample images:

  • Copy the URL and open it in a new browser tab. This will download a .zip file, which contains several sample images.
  • Extract the compressed files to your computer, in a location of your choice.
  • Navigate to the extracted files to access the sample images. You should see 10 .png files in the directory, which you can use when adding new employees.
  1. Choose Add.

  2. For extra hands-on practice, create a few more employees, edit some items, and delete some items.

  3. To confirm the photos have been uploaded to an S3 bucket, in the AWS Management Console, on the Services menu, choose S3. Alternatively, you can type the service name in the Search box to access it.

  4. Choose the link for the bucket with imagesbucket in the name of the bucket.

  5. In the Objects tab, you can confirm the number of photos the application uploaded (and names of files uploaded) with the number of files (and names of files) in the S3 bucket.

In the next task, you will validate that the items are added to the DynamoDB table, and you will use the AWS Management Console to edit them.

Task 3: Manage DynamoDB Items Using the AWS Management Console

In this task, you will see how the employee items are stored in DynamoDB.

  1. In the AWS Management Console, on the Services menu, locate the Database section, and choose DynamoDB. Alternatively, you can type the service name in the Search box to access it.

  2. In the left navigation pane, choose Tables.

  3. In the Tables list, choose the Employees link.

You should see details about the Employees table.

  1. Review the instance's details, including its general information, items, indexes, and so forth.

  2. Choose Explore table items.

In the Items returned section, you can now see the items in the database made from the Amazon Elastic Compute Cloud (Amazon EC2) service.

  1. To review an item, choose the column link.

The Item editor screen shows the item's attributes. Alternatively, to access the representation, choose JSON at the top.

Using the Form view, you can change the name, location, and email address fields.

Important: You will receive an error if you try to modify the primary key field, . That field cannot be modified. To modify it, you must delete the item and add it again.

  1. Update the location and email values in , and then choose Save changes.

Note: Ignore the attribute. It is beyond the scope of this lab.

Tip: As you make changes, go to your browser's tab where the Employee Directory application is displayed, and confirm that the changes appear.

Task 4: Create Items in a DynamoDB Table Using the AWS Management Console

In this task, you will use the console to create items.

  1. Go to your browser's tab where the DynamoDB dashboard lists the available tables.

  2. In the Tables list, choose the Employees link.

  3. Choose Explore table items.

  4. To the right of Employees header, choose Create item.

  5. Ensure that Form is selected when editing items.

  6. In the Attributes section, provide a value for . The must be unique across all items in the table.

  7. Choose Add new attribute , and select .

  8. Replace with , and provide a value for name. For example, John.

  9. Choose Add new attribute , and select .

  10. Replace with , and provide a value for location. For example, New York.

  11. Choose Add new attribute , and select .

  12. Replace with , and provide a value for email. For example, john.doe@example.org.

  13. Choose Add new attribute , and select .

  14. Replace with , and leave the field empty.

  15. Choose Create item.

  16. Go to your browser's tab where the Employee Directory application is displayed, and confirm that the new item displays in the Employees list.

Note: If needed, refresh your browser's tab to see the new item.

  1. For more hands-on practice, create a few more employees, edit some items, and delete some items. Make sure that you provide the four required attributes: , , , and (empty) .

Lab Complete

Congratulations! You completed the lab.

End lab

Follow these steps to close the console, end your lab, and evaluate your lab experience.

  1. Return to the AWS Management Console.

  2. At the upper-right corner of the page, choose awsstudent@<AccountNumber>, and then choose Sign out.

  3. Choose End Lab.

  4. Choose OK.

  5. (Optional):

  • Select the applicable number of stars to rate your lab experience.
    • 1 star = Very dissatisfied
    • 2 stars = Dissatisfied
    • 3 stars = Neutral
    • 4 stars = Satisfied
    • 5 stars = Very satisfied
  • Enter a comment.
  • Choose Submit.

You can close the window if you don't want to provide feedback.

Additional Resources