Amazon DynamoDB Tutorial for Beginners

Amazon DynamoDB Tutorial for Beginners

Introduction

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!

Preparation

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:

  1. AWS account Setup – You’ll need an AWS Account for this tutorial. To create an account, click?here, and simply follow the instructions in Neal’s video tutorial on?How to create an AWS Free Tier Account.
  2. You’ll also need a user with root privileges and both the user’s access key ID and secret access key. Click?here?to learn more.
  3. We will also be using a JSON file to populate items in the table. Click?here?to download this JSON file to your computer.
  4. Lastly, you’ll need to install the AWS CLI. Click?here?and 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”.

No alt text provided for this image

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.

No alt text provided for this image

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.

No alt text provided for this image

Now let’s navigate to DynamoDB by clicking on “Services” and then “DynamoDB”.

No alt text provided for this image

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.

No alt text provided for this image

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.

No alt text provided for this image

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 alt text provided for this image

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.

No alt text provided for this image

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.

No alt text provided for this image

The following output indicates that?things are running correctly.

No alt text provided for this image

Let’s scan our table by running the second command listed below.

No alt text provided for this image

You’ll see a scan of the document for data to be uploaded. This is being copied to your DynamoDB table.

No alt text provided for this image

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.

No alt text provided for this image

Enable Point-in-time Recovery

Under your table click on “Backups” and then under “Point-in-time recovery” click on the “Edit” button.

No alt text provided for this image

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.”

No alt text provided for this image

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:

This article by Neal Davis originally appeared on the Digital Cloud Training Blog: "Amazon DynamoDB Tutorial for Beginners"


Neal K. Davis

I've helped over 1 million cloud enthusiasts build hands-on skills and elevate their careers ?? Founder of Digital Cloud Training | AWS Community Builder | Cloud Solutions Architect | Udemy Instructor Partner

3 年

#aws #amazonwebservices #amazonaws #cloudcomputing?#dynamodb

回复

要查看或添加评论,请登录

Neal K. Davis的更多文章

社区洞察

其他会员也浏览了