DynamoDB Dynamo: AWS CLI Commands for NoSQL Database
Last Updated :
23 Jul, 2025
As we know, there are three main ways to access and manage AWS services, AWS CLI (command line interface), the AWS Management Console, and the AWS SDK(Software (software kit). Here we are working with the first tool, which is AWS CLI (command line interface) which is basically used for interacting with AWS Resources through scripting and automation functionality of the AWS CLI. In this article, we are deep-diving into working with DynamoDB through AWS CLI and we know that AWS DynamoDB is a managed NoSQL database service that is serverless, AWS and we use it when we have large amounts of data and need to read/write frequently.
Key Points
Before we start to explore our main topic, we just need to understand some of the following points:
- Table: It is a collection of data in DynamoDB, and it's similar to a relational database table.
- Item: It is a single record in the table or collection of attributes, and it's similar to raw in the relational database.
- Attribute: It basically stores the data into items like key-value pairs. and it's similar to a column in the relational database.
- Primary Key: It is a unique identifier for each item that is present in a table, It can be
- partition key: For a single attribute.
- partition key and sort key: For a combination of two attributes.
- Provisioned Throughput: It is basically capacity that is assigned to the DynamoDB table, and it is defined in terms of units.
- Global Secondary Index (GSI): It is an index with partition and sort keys, and literally, it is different from those on the base table.
- Local Secondary Index (LSI): It is also an index with the same partition key as those on the base table, but the sort key is different.
Step-by-step guidance to use AWS CLI for DynamoDB
Before starting, Make sure that you have an AWS Account with the needed permission to manage DynamoDB resources and AWS CLI installed and configured on your system.
Note: When you work with the Windows command prompt, some syntax issues come up. We should write " instead of '' and \" instead of ". For example, "{\": year\":{"N":"2023"}}".
Step 1: Configuring AWS CLI
- Install AWS CLI: Follow the instructions from the AWS CLI documentation for installing AWS CLI as per your operating system.
- Configure AWS CLI: After Installing AWS CLI you configure your AWS CLI through the following command.
aws configure
After that you enter some necessary information such as,
IAM Permissions
If you want to manage the DynamoDB resources using AWS CLI, first check that the IAM user or role has the following permissions:
- dynamodb:CreateTable
- dynamodb:PutItem
- dynamodb:GetItem
- dynamodb:Query
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:DeleteTable
Creating and attaching custom IAM Policy
aws iam create-policy \
--policy-name DynamoDBManagementPolicy \
--policy-document '{
"Version": "2024-05-25",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:CreateTable",
"dynamodb:PutItem",
"dynamodb:GetItem",
"dynamodb:Query",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:DeleteTable"
],
"Resource": "*"
}
]
}'
Attach the policy to your IAM user or role
aws iam attach-user-policy
--policy-arn arn:aws:iam::YOUR_ACCOUNT_ID:policy/DynamoDBManagementPolicy
--user-name YOUR_IAM_USERNAME
Step 2: Creating a DynamoDB Table
Here, we use the create-table command for DynamoDB table creation. Here, I create a movie table with a primary composed of year and title in the below example.
aws dynamodb create-table
--table-name Movies
--attribute-definitions
AttributeName=year,AttributeType=N
AttributeName=title,AttributeType=S
--key-schema
AttributeName=year,KeyType=HASH
AttributeName=title,KeyType=RANGE
--provisioned-throughput
ReadCapacityUnits=5,WriteCapacityUnits=5
You can check the result in the AWS Command Line interface by using the command given above.
Picture 2.1: You can check the result in the AWS Command Line interface by using the command given above.
Picture 2.1Picture 2.2: You can check the result in the AWS Management Console by using the command given above.
Picture 2.2Step 3: Inserting Data into the Table
Here, we use the put-item command to put an item into the table. In the below example, it shows that a movie record is being inserted.
aws dynamodb put-item
--table-name Movies
--item
'{"year": {"N": "2023"}, "title": {"S": "Example Movie"}, "info": {"S": "Sample data"}}'
Picture 3.1: You can check the result in the AWS Command Line interface by using the command given above.
Picture 3.1Picture 3.2: You can check the result in the AWS Management Console by using the command given above.
Picture 3.2Step 4: Querying Data from the Table
Here, we use the query command to query data in the table. In the below example, it basically shows that it retrieves all movies that were released in 2023.
aws dynamodb query
--table-name Movies
--key-condition-expression "year= :year"
--expression-attribute-values '{":year":{"N":"2023"}}'
Picture 4.1: You can check the result in the AWS Command Line interface by using the command given above.
Note: When you work with the Windows command prompt, some syntax issues come up. In the above command 'year', you need to change '#yr' because year is a reserved keyword in DynamoDB. and We Should write " " Instead of ' ' and \" Instead of " . For example, "{\":year\":{"N":"2023"}}".
Picture 4.1Picture 4.2: You can check the result in the AWS Management Console by using the command given above.
Picture 4.2Step 5: Updating Data
Here, we use the update-item command to update existing item into the table. In the below example, it shows that updates the info attribute for a specific movie.
aws dynamodb update-item
--table-name Movies
--key '{"year": {"N": "2023"}, "title": {"S": "Example Movie"}}'
--update-expression "set info = :info"
--expression-attribute-values '{":info":{"S":"Updated info"}}'
Picture 5.1: You can check the result in the AWS Command Line interface by using the command given above.
Picture 5.1Picture 5.2: You can check the result in the AWS Management Console by using the command given above.
Picture 5.2Step 6: Deleting Data
Here, we use the delete-item command to delete an item from the table. In the below example, it shows that it deletes a specific movie record.
aws dynamodb delete-item
--table-name Movies
--key '{"year": {"N": "2023"}, "title": {"S": "Example Movie"}}'
Picture 6.1: You can check the result in the AWS Command Line interface by using the command given above.
Picture 6.1Picture 6.2: You can check the result in the AWS Management Console by using the command given above.
Picture 6.2Step 7: Deleting a Table
Here, we use the delete-table command, which deletes a table.
aws dynamodb delete-table
--table-name Movies
Picture 7.1: You can check the result in the AWS Command Line interface by using the command given above.
Picture 7.1Picture 7.2: You can check the result in the AWS Management Console by using the command given above.
Picture 7.2Conclusion
Using the AWS CLI to manage DynamoDB objects allows for efficient automation and scripting of database operations. This guide covered important operations such as creating tables, inserting data, querying, updating and deleting data. AWS CLI increases performance and stability, especially for highly managed data with frequent read/write operations. The benefits of these commands simplify operations and help maintain robust, scalable, and reliable applications in a server-less environment.
Similar Reads
DevOps Tutorial DevOps is a combination of two words: "Development" and "Operations." Itâs a modern approach where software developers and software operations teams work together throughout the entire software life cycle.The goals of DevOps are:Faster and continuous software releases.Reduces manual errors through a
7 min read
Introduction
What is DevOps ?DevOps is a modern way of working in software development in which the development team (who writes the code and builds the software) and the operations team (which sets up, runs, and manages the software) work together as a single team.Before DevOps, the development and operations teams worked sepa
10 min read
DevOps LifecycleThe DevOps lifecycle is a structured approach that integrates development (Dev) and operations (Ops) teams to streamline software delivery. It focuses on collaboration, automation, and continuous feedback across key phases planning, coding, building, testing, releasing, deploying, operating, and mon
10 min read
The Evolution of DevOps - 3 Major Trends for FutureDevOps is a software engineering culture and practice that aims to unify software development and operations. It is an approach to software development that emphasizes collaboration, communication, and integration between software developers and IT operations. DevOps has come a long way since its in
7 min read
Version Control
Continuous Integration (CI) & Continuous Deployment (CD)
Containerization
Orchestration
Infrastructure as Code (IaC)
Monitoring and Logging
Microsoft Teams vs Slack Both Microsoft Teams and Slack are the communication channels used by organizations to communicate with their employees. Microsoft Teams was developed in 2017 whereas Slack was created in 2013. Microsoft Teams is mainly used in large organizations and is integrated with Office 365 enhancing the feat
4 min read
Security in DevOps