Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. In this tutorial, we will guide you through the process of creating and configuring a DynamoDB table using the AWS Management Console and AWS CLI.
DynamoDB tables consist of items, which are composed of attributes. Each attribute has a name and a value. DynamoDB supports various data types for these attributes, including strings, numbers, binary data, sets, lists, and maps. Tables in DynamoDB can be configured with different settings such as read/write capacity modes, indexes, and encryption.
Log in to the AWS Management Console:
Navigate to DynamoDB:
Create a New Table:
MyFirstTable.id as the attribute name and set its type to String.Configure Additional Settings:
Review and Create:
Install AWS CLI:
Configure AWS CLI:
$ aws configure
Create a DynamoDB Table:
aws dynamodb create-table command to create a new table. Here's an example command:
1aws dynamodb create-table --table-name MyFirstTable --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
MyFirstTable with a single partition key (id) of type String. It also sets the read and write capacity units to 5.Verify Table Creation:
$ aws dynamodb list-tables
MyFirstTable in the list of tables.Insert an Item Using AWS CLI:
aws dynamodb put-item command to insert an item into your table. Here's an example command:
1aws dynamodb put-item --table-name MyFirstTable --item '{2"id": {"S": "1"},3"name": {"S": "John Doe"},4"age": {"N": "30"}5}'
id as 1, name as John Doe, and age as 30.Retrieve the Item:
aws dynamodb get-item command:
1aws dynamodb get-item --table-name MyFirstTable --key '{2"id": {"S": "1"}3}'
In this tutorial, we learned how to create and configure a DynamoDB table using both the AWS Management Console and AWS CLI. In the next section, we will explore how to query data in DynamoDB, allowing us to retrieve and manipulate the data stored in our tables.
Feel free to experiment with different configurations and settings to suit your application's needs. DynamoDB offers powerful features for managing large-scale applications with high availability and performance.