top of page
Writer's pictureParag

Amazon DynamoDB NoSQL database

Updated: Jul 23, 2021

Learn to create an Amazon DynamoDB NoSQL database table and populate using Amazon EC2 Instance.


Objectives:

1. Learn to create an Amazon DynamoDB NoSQL database table.

2. Populate using Amazon EC2 Instance.

Step 1: Go to Dynamo DB service in AWS console. Click on Create Table.

Table Name: ProductCatalog

Primary Key: Id Type: Number

Keep the rest as default and click on Create.


Step 2: Now we create a role for accessing providing EC2 access to Dynamo DB.

Go to IAM service from AWS console. Click on Roles. Click Create role.

Choose the EC2 use case. Proceed to Next: Permissions.

Search and select AmazonDynamoDBFullAccess policy.

Continue to tags and further to Review. Configure as follows:

Role name: EC2RoleForDynamoDB

Role Description: Allows EC2 instances to call AWS DynamoDB service on your behalf.

Click on Create Role at the bottom corner of screen.


Step 3: Launch an EC2 Linux Instance. For step by step instructions to launch EC2 instance visit our blog here.

After the instance is in running state.

Go to Actions -> Security -> Modify IAM Role

Select the DynamoDB role created in previous step and Save.


Step 4: SSH or Connect through AWS Management Console to the instance.


Run the following command to update the Linux instance.

sudo yum update


It would ask for confirmation. Enter Y and complete the update.


Further use the following command to get the data.

wget https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/samples/sampledata.zip


Run the ls command once to confirm.



Unzip this data file using the next command:

unzip sampledata.zip


Now we write these files using next command. Change the highlighted part specific to the region you are operating in:

aws dynamodb batch-write-item --request-items file://ProductCatalog.json --region ap-south-1


Step 5: Now we go back to Dynamo DB console and when you refresh the table, it is observed to be populated.

We try to run a query in DynamoDB. In the Scan drop down above table select Query in drop down.

Provide a Number for Id and and run the query.


Note: After the completion of this tutorial, Delete the DynamoDB table and the EC2 Instance.



Was this document helpful? How can we make this document better. Please provide your insights. You can download PDF version for reference.


For AWS certification / AWS trainings needs contact us.





275 views32 comments

32 comentários


pratik gajare
pratik gajare
17 de jun.

useful

Curtir

Piyush Patil
Piyush Patil
04 de jun.

very useful sir


Curtir

Tanaya Yalrute
Tanaya Yalrute
23 de abr.

Redone to revise

Curtir

Shruti Bhosekar
Shruti Bhosekar
14 de fev.

Good blog sir!

Curtir

Rucha Kulkarni
Rucha Kulkarni
13 de fev.

Well Explained


Curtir
bottom of page