AWS Database Blog
Everything you ever wanted to know about the Amazon DynamoDB console but were afraid to ask: A detailed walkthrough
Since its release in 2012, Amazon DynamoDB has become a fully managed, multi-region, multimaster database service designed to deliver fast and predictable performance at any scale. DynamoDB is a NoSQL database that provides three options for performing operations: a web-based console, the AWS Command Line Interface (CLI), and a set of SDKs for a number of programming languages.
In this blog post, I walk through the DynamoDB console to help you better understand DynamoDB core components (tables, items, and attributes), global tables, read/write capacity modes, purchasing reserved capacity, and backup mechanisms.
A detailed walkthrough of the DynamoDB console
To get started with the DynamoDB console:
- Go to the DynamoDB homepage, and choose Get started with Amazon DynamoDB. (If you haven’t already set up an AWS account, choose Create an AWS Account, and you will be guided through the process of setting one up.)
- Sign in to the AWS Management Console, and then open the DynamoDB console.
If this is your first time on the DynamoDB console, you see a Welcome page that displays information about DynamoDB and how you can use it. The Welcome page offers three options for performing common operations:
- Create tables
- Add and query items
- Monitor and manage tables
After your first visit to the DynamoDB console, you always start on the Dashboard page of the console. The dashboard provides details about recent alerts triggered by Amazon CloudWatch alarms, the total provisioned capacity of tables, service health, and other information about DynamoDB.
As numbered in the preceding screenshot, the sections of the dashboard include:
|1||Create table||Allows you to create a table directly from the dashboard.|
|2||Recent alerts||Shows a list of alerts, courtesy of CloudWatch alarms. The alerts help you monitor your table’s capacity usage.|
|3||Total capacity for the chosen AWS Region||Provides an overview of the total capacity units in use (both read and write capacity mode) in the AWS Region in which you access the DynamoDB console:
The read/write capacity mode controls how you manage capacity and how you are charged for read and write throughput. You can set the read/write capacity mode when creating a table, or you can change it later.
|4||Service health||Keeps you informed of any DynamoDB-related outages in a Region. Alternatively, you can go directly to the Service Health Dashboard.|
|5||Related information||Provides links to information about recent launches and other related features, services, and information.|
The core components of DynamoDB are tables, items, and attributes. DynamoDB stores data in tables, and a DynamoDB table is a collection of items. Each item, which is uniquely identifiable among all of the other items, is a collection of attributes. In DynamoDB, items and attributes are similar to rows/records/tuples and fields/columns in other database systems. In an Employee table, for example, each item could represent an employee and could contain attributes called
FirstName, and so on.
The process of creating a table includes naming the table, establishing its primary key attributes, and setting attribute data types. In this section of the walkthrough, I show how to use the DynamoDB console to create and update a table, and show the tabs associated with the table and explain their use.
To create a DynamoDB table:
- From the Tables page in the DynamoDB console, choose Create table.
- On the Create DynamoDB table page, enter a Table name, and then provide the Primary key information. For the example, I enter
Console_testDBfor Table name, and
EmployeeIDas the Partition key attribute in the Primary key. I also set the data type of the Partition key to Number from the drop-down list.
When working with a NoSQL database such as DynamoDB, a key-value pair is a set of two linked data items: a key, which is a unique identifier for items in a table, and a value, which is either the data that is identified or a pointer to the location of that data. In DynamoDB, each item in a table has a unique identifier, or primary key, that distinguishes the item from all other items in the table. No two items can have the same key. The primary key can consist of one attribute (a partition key, referred to as a simple primary key) or two attributes (a partition key and a sort key, referred to as a composite primary key). You need to provide the attribute names, data types, and the role of each attribute:
HASH for a partition key or
RANGE for a sort key.
Each primary key attribute must be a scalar, meaning that it can hold only a single value. When working with DynamoDB, you have a choice of making the key a number, a string, or a binary value. For the example we’re using here, the
EmployeeID is the primary key that provides a unique value across all employees.
- Continuing with the example, I select the Add sort key check box, enter
EmployeeNamein the text box, and then choose String as the data type from the drop-down list. Notice that the Sort key box is connected to the Partition key box, which means that the two fields are essentially used together. Using a sort key lets you locate data by using more than just the primary key.
- To finish creating the table, I choose to Use default settings, and then choose Create. The default settings create a DynamoDB table that:
- Does not include a secondary index.
- Uses a specified provisioned capacity.
- Sets alarms for occasions when applications exceed the provisioned capacity.
- Provides encryption at rest with the default encryption type, which is the AWS owned customer master key (CMK).
Organizational policies, industry or government regulations, and compliance requirements often require the use of encryption at rest to increase the data security of your applications. DynamoDB encryption at rest provides an additional data protection layer by securing data in an encrypted table. The encrypted data includes the table’s primary key, local and global secondary indexes, streams, global tables, backups, and DynamoDB Accelerator (DAX) clusters. DynamoDB integrates with AWS Key Management Service (AWS KMS) to manage the encryption key that is used to encrypt your tables.
Provisioned capacity determines the number of reads and writes you expect your table to have per second. For this test setup, a provisioned capacity setting of five read capacity units and five write capacity units should work well for the table we’re creating.
You can now see the Console_testDB table that you’ve created on the Tables page of the DynamoDB console, as shown in the following screenshot. Each tab on the Tables page includes information about the table. The More link to the right of the list of tabs tells you that you can access even more tabs. Alternatively, you can click the left-pointing arrow (to the left of Create table) to hide the navigation pane so that you can view all tabs at once.
Let’s look at the tabs on the Tables page of the DynamoDB console.
The Overview tab (see the preceding screenshot) includes recent alerts triggered for the table, details about DynamoDB Streams, and table details such as the table name, partition key, sort key, date and time of the table’s creation, and the table’s provisioned throughput settings.
When you enable DynamoDB Streams on a table, DynamoDB captures a time-ordered sequence of every modification made to an item in the table and stores this information in a log for up to 24 hours. Applications can access this log and view the data items as they appeared before and after they were modified in near-real time. You can build applications that consume these streams and take action based on the contents.
A table in DynamoDB consists primarily of items and attribute specifications and optional conditions. Each item exists as a set of attributes, with each attribute named and assigned a value of a certain type. You use the Items tab to create and edit items.
To create an item by using the DynamoDB console:
- Choose Create item. Enter the attribute values on the Create item. Also enter any secondary indexes.
- For the example in this post, I enter
26as the EmployeeID value and
Bobas the EmployeeName value.
- If you require more attributes, choose the plus sign to the left of EmployeeName (see first screenshot that follows). Then choose Append and the desired data type. For this walkthrough, I choose String as the data type, add
EmployeeTitleas the string value, and add
IT Engineeras the attribute value, as shown in the second screenshot that follows. You can repeat the process to add new items to the table. I repeated the process to add
- After entering all essential information, choose Save to add the item. You now will see all the newly created items and attributes, and you can choose Actions to perform various operations on items, such as Duplicate, Edit, and Delete, as shown in the first screenshot that follows. You also can perform a query or scan operation on the items in a table.
When you interact with DynamoDB, it sends metrics and dimensions to Amazon CloudWatch. DynamoDB sends metrics to CloudWatch only when the metrics have a nonzero value.
You can create a CloudWatch alarm to be notified when metric data reaches a level that you define. When the alarm changes state, Amazon SNS sends a notification to you. For our example, two alarms were created as part of the default settings of the table.
On the Capacity tab, you specify throughput requirements in terms of capacity units (how much data your application needs to read or write per second). You can modify these settings later, or you can enable DynamoDB auto scaling to modify the settings automatically.
This tab provides an overview of the read and write capacity mode in use for the table, capacity units configured for provisioned mode, and auto scaling activities enabled for the table. I used the default setting while creating the table Console_testDB, which uses provisioned capacity. However, DynamoDB has two read/write capacity modes for processing reads and writes on your tables: on-demand capacity mode (no capacity planning and pay-per-request pricing) and provisioned capacity (the default with Free Tier eligibility).
You can choose the on-demand read/write capacity mode when creating a new table, or change it later on the Capacity tab. Tables using on-demand capacity mode support all DynamoDB features—such as encryption at rest, point-in-time recovery (PITR), and global tables—with the exception of auto scaling. Note that you can change a table from provisioned capacity to on-demand every 24 hours, and you can switch it back to provisioned capacity immediately, if necessary.
The Indexes tab provides a list of all of the configured indexes for your table. Indexes accelerate application access and data retrieval, and support better performance by reducing application lag. A secondary index contains an attribute subset from a table and an alternate key (partition key and sort key) to support either a
Scan operation against the index for data retrieval. DynamoDB offers two types of secondary indexes: global secondary indexes and local secondary indexes.
Global Tables tab
DynamoDB global tables are ideal for massively scaled applications that have a large, geographically dispersed user base. Global tables provide a fully managed solution for deploying a multi-region, multimaster database without requiring you to build and maintain your own replication solution. In other words, global tables provide automatic replication to AWS Regions worldwide so that you can deliver low-latency data access to your users, regardless of their location.
One use case for a global table is a large customer base spread across three geographic areas (such as the East Coast and West Coast of the United States, and Western Europe) where customers need to update their profile information when using your application. To address these requirements, you could create three identical but separate DynamoDB tables named CustomerProfiles in three different AWS Regions. Because these three tables would be separate from each other, changes to the data in one table would not be reflected in the other tables. Without a managed replication solution, you could write code that would replicate data changes among these tables; however, this would involve excessive manual overhead.
Instead, you could create a global table consisting of your three region-specific CustomerProfiles tables. DynamoDB would then automatically replicate data changes among the tables so that changes to CustomerProfiles data in one region are propagated to the other Regions. The other benefit to using a global table is that if one of the AWS Regions became temporarily unavailable, your customers could still access the same CustomerProfiles data in the other two Regions.
For detailed information about creating a table in the DynamoDB console, see Creating a Global Table.
You can use the Backups tab to create an on-demand backup of a table, or you can choose Backups in the console’s navigation pane. You can also enable point-in-time recovery (PITR) for your DynamoDB tables. PITR provides continuous backups of your DynamoDB table data. See Restoring a Table to a Point in Time (Console) to learn more.
To learn how to create an on-demand backup, see Creating a Table Backup (Console). To restore a table from a backup, see Restoring a Table from a Backup (Console), and to delete an on-demand backup, see Deleting a Table Backup (Console).
DynamoDB triggers connect DynamoDB Streams to AWS Lambda functions. When an item in your table is modified, a new stream record is written, which in turn triggers a Lambda function and causes it to execute. For more information, see DynamoDB Streams and AWS Lambda Triggers.
Access control tab
Use fine-grained access control to help limit and control direct database access by mobile apps. Web identity federation allows your mobile apps to use identity providers such as Login with Amazon, Facebook, and Google.
You can label DynamoDB resources with tags that help to categorize your resources and provide cost insights by allowing you to create reports based on specific tags. For more information about how to create tags, see Tagging (console).
In addition to the Backups tab I already discussed, the DynamoDB console provides access to a separate Backups page, from which you can create on-demand backups.
Note: If you create backups using the Backups section in the navigation pane, the table isn’t preselected for you. You have to manually choose the source table name for the backup.
If you are able to predict your need for DynamoDB read and write throughput in a given AWS Region, you can save money with reserved capacity by paying a one-time, upfront fee and committing to a minimum usage level over a 1-year or 3-year period. Reserved capacity is not available with DynamoDB on-demand and is a feature supported in provisioned capacity only.
Before purchasing reserved capacity for your DynamoDB tables, you need to determine how much read and write capacity throughput your tables consume by using ConsumedReadCapacityUnits and ConsumedWriteCapacityUnits CloudWatch metrics. The data recorded by these metrics enables a more reliable understanding of your DynamoDB usage patterns and can help you to predict the number of units needed. Determining whether it is beneficial to purchase reserved capacity for read or write capacity units (or both) depends on your application and use case. For example, if you have a read-heavy application, you might purchase 30,000 read capacity units and 20,000 write capacity units with reserved capacity. After you have done this, you can use that capacity to provision tables for the duration of the reservation.
If you’re signed in to the DynamoDB console as an AWS Identity and Access Management (IAM) user, you can store information about how you prefer to use the console. This information, also known as your user preferences, is stored and applied every time you use the console. Whenever you access the console, these preferences are applied to all tables in all AWS Regions.
User preferences are available only for IAM users. You cannot set preferences if you use federated access, temporary access, or an AWS account root user to access the console. For more information about how to view and change console user preferences, see View and Save User Preferences.
How to delete the example table
I’ll now walk you through the process of deleting a table by deleting the example I created in this walkthrough:
- Choose Delete table on the Tables page of the console.
- A pop-up window asks you to confirm your choice with two options: Delete all CloudWatch alarms for this table (chosen by default) and Create a backup before deleting this table. Enabling the latter option is useful in situations where data from a deleted table must remain available. If you choose the latter option, you will have a backup of the deleted table on the Backups page of the console.
- Choose Delete to complete the deletion of the table.
In this blog post, I walked through the DynamoDB console, what you can do on the console, and how to access all features. I also provided an example of how to create a table by using the console, create items in the table, and then delete the table.
In a future AWS Database Blog post, I will walk through the DAX part of the DynamoDB console.
About the author
Ishita Mehta-Desai is a technical account manager at AWS. She enjoys providing technical guidance to customers and exploring new places.