DynamoDB

In this lab you will experiment the Amazon DynamoDB.

Prerequisites

For this lab you just need to have your AWS CLI properly configured, or execute this lab from a Cloud9 or EC2 Instance using a role with permissions to operate over DynamoDB.

Context

As your first taste of Amazon DynamoDB, you will create a table, insert a record, and query it.

If you are running this lab in a single-account/multiple users environment, don't forget to add a <prefix> to the name of the resources that you are creating.


Task 1. Create a table using the AWS console.

  1. Go to the DynamoDB home: https://console.aws.amazon.com/dynamodb.
  2. Click on Create table.
  3. For Table name, type <prefix>Product.
  4. For Primary key*, type Id.
  5. For Table Settings, use default settings.
  6. Click on Create.
  7. Wait the table to be created.

Task 2. Insert a record.

  1. Select the tab Items and click on Create item.
  2. The pop up window Create item will be shown. Select the option Text.
  3. Fill in the details as shown below
    {
    "Id": "PRD01", "Description": "UNICORN GENERATOR", "LatestStockUpdate": "2019-10-22T22:15:34Z", "Suppliers": [ "S045", "S4456", "ACME126" ] }
  4. Click on Save.

Task 3. Use AWS CLI to query the table.

  1. Get back to the console on your computer or on Cloud9.
  2. Let's check if the table is there. Be sure of using the correct region.
    $ aws --region <REGION> dynamodb list-tables
     {
        "TableNames": [
            "Product"
            ...
        ]
    }       
    
  3. Other tables may appear if you have other tables on your account, in that particular region.
  4. Access the console and submit the query using the AWS CLI. You will need to specify the region for the table.
    $ aws --region <REGION> dynamodb get-item --table-name Product --key '{"Id" : { "S":"PRD01"}}'
    {
        "Item": {
            "LatestStockUpdate": {
                "S": "2019-10-22T22:15:34Z"
            }, 
            "Id": {
                "S": "PRD01"
            }, 
            "Suppliers": {
                "L": [
                    {
                        "S": "S045"
                    }, 
                    {
                        "S": "S4456"
                    }, 
                    {
                        "S": "ACME126"
                    }
                ]
            }, 
            "Description": {
                "S": "UNICORN GENERATOR"
            }
        }
    }


Finishing the lab

You have finished this lab.

Now, you can delete all the resources from your account.