Please use the menu below to navigate the article sections:
Amazon DynamoDB is Amazon Web Service’s (AWS) fully managed NoSQL database service. DynamoDB has high performance and scalability that wouldn’t be possible in a traditional data center. DynamoDB can automatically scale up and down to meet demands making it a cost-effective solution for many use cases. It is also a fully managed option meaning AWS will provision what you need to get the job done.
DynamoDB also has on-demand backup and point-in-time recovery capabilities that allow users to easily roll back if needed. DynamoDB is used by many businesses today and having hands-on experience about how to manage this database option will help you in your career.
In this Amazon DynamoDB tutorial for Beginners, we’ll create a DynamoDB table, enable point-in-time recovery, and make an on-demand backup. These are the essentials when it comes to working with DynamoDB. So, let’s get started!
There are a few steps you’ll need to take to prepare your AWS account and the tools and files you need before starting the DynamoDB tutorial:
- AWS account Setup – You’ll need an AWS Account for this tutorial. To create an account, simply follow the instructions in Neal’s video tutorial on How to create an AWS Free Tier Account.
- You’ll also need a user with root privileges and both the user’s access key ID and secret access key.
- We will also be using a JSON file to populate items in the table. Download this JSON file to your computer.
- Lastly, you’ll need to install the AWS CLI. Follow the steps for your operating system.
Amazon DynamoDB Tutorial for Beginners – Creating a Table
After accessing your CLI, run the following command to create a profile called “dct-prod”. This will help if you have more than one user. If this is the first AWS user on your computer you can simply run “aws configure”.
Enter your Access Key ID and Secret Access Key as prompted. You’ll then insert your default region. This can be found by clicking on your region toward the top right of the AWS Management Console.
Run the following command to check for any S3 buckets in your account. If you logged in successfully and had S3 buckets previously they should appear here. This proves that the AWS CLI is successfully configured with the credentials we supplied.
Now let’s navigate to DynamoDB by clicking on “Services” and then “DynamoDB”.
Click on “Create Table”.
Give your table a name. We named ours “mystore” because the JSON file has items you’d find in a shop.
Next, you’ll want to set your table up with keys. For the Partition key enter “clientid”. For the Sort Key write “created”. These keys are a way of organizing items in our database.
We’ll now want to customize our database configuration. Click on “Customize Settings”. Also, click “Provisioned” as this will allow us to configure our database in more detail.
It’s good to note that target scaling policies can be configured at the creation of a DynamoDB table. Here we give our DynamoDB service a minimum of 1 unit, a maximum of 4 units, and a target utilization goal of 70%.
No need to enter anything under “Secondary indexes.” For “Encryption at rest” click on “owned by Amazon DynamoDB”, then click on “Create Table”.
Upon successful creation, you should see your table “mystore” appear.
Now, let’s switch over to a command-line interface. Here we’ll run the following command to request items from the JSON file we downloaded at the beginning of the tutorial.
The following output indicates that things are running correctly.
Let’s scan our table by running the second command listed below.
You’ll see a scan of the document for data to be uploaded. This is being copied to your DynamoDB table.
Return to your DynamoDB table. Click on “Items” and then refresh the page.
If the commands ran successfully you should see a list of items stored in the “mystore” table.
Enable Point-in-time Recovery
Under your table click on “Backups” and then under “Point-in-time recovery” click on the “Edit” button.
Click on “Enable Point-in-time-recovery” and then “Save Changes”. You’re now able to restore your DynamoDB to a previous point-in-time. Use this for rolling back from accidental deletions or errors.
Create a Backup
Navigate to “Backups”. Under “On-demand backups”, click on “Create backup”.
For “Source table” select the table you created earlier and give your backup a name. Then click on “Create backup.”
Congratulations! You’ve completed this DynamoDB Tutorial for Beginners! You’ve set up a DynamoDB table, enabled point-in-time recovery, and created a backup. You’re off to a great start understanding DynamoDB. There’s still lots more to learn about Amazon DynamoDB and you can take your knowledge to the next level with our AWS training courses.
AWS Training Courses
Amazon DynamoDB features in several of our AWS certification training courses including the following:
- AWS Certified Cloud Practitioner
- AWS Certified Solutions Architect Associate
- AWS Certified Developer Associate
- AWS Certified Solutions Architect Professional