Creating a DynamoDB Table and Setting Up IAM Access Control

rashmitha_v_d0cfc20ba7152

Rashmitha v

Posted on July 8, 2024

Creating a DynamoDB Table and Setting Up IAM Access Control

Introduction to DynamoDB Tables
Amazon DynamoDB is a fully managed NoSQL database service provided by AWS (Amazon Web Services). It offers high performance, seamless scalability, and low latency for applications needing consistent, single-digit millisecond response times. DynamoDB is particularly well-suited for applications requiring fast and predictable performance with seamless scalability.

Architecture:

Image description

_Step 1:Create a DynamoDB table for student details _

Navigate to the DynamoDB dashboard and click “Create table”, as show below.
Image description

  • When creating your DynamoDB table, you need to choose a name for the table and specify a Partition key.

  • The Partition key determines the partition in which the data is stored, while the Sort key helps in sorting the data within the partition based on its value.

  • Once you have named your table and assigned a partition key, navigate to the “Table settings” section.

  • simply click the “Create table” button in orange to initiate the table creation process

Step2 :Add items to DynamoDB table

Choose your recently created table from the list. In the left panel, click on “Explore items” and then select “Create item” to begin creating a new item within the table.

Image description
We are adding 6 student detail to the table.

Image description
Step 3: Launch EC2 with IAM role to scan DynamoDB table
Launching an EC2 instance with an IAM role that allows it to scan a DynamoDB table involves several steps, including creating an IAM role with appropriate permissions, launching the EC2 instance with that IAM role, and writing code on the EC2 instance to interact with DynamoDB.

In the next screen, give your role a name and click “Create role.”
step 4: Attach Policy

In the permissions tab, click "Attach policies directly".

Image description

Search for and attach the AmazonDynamoDBReadOnlyAccess policy (or create a custom policy with specific dynamodb:Scan permissions).

Step 5: Use the AWS CLI in the EC2 instance to scan the DynamoDB table
Navigate to the EC2 dashboard, then select your EC2 Instance.Then connect into your EC2 Instance by selection one of these ways:

Image description
I selected EC2 Instance Connect. We are now connected to our instance and ready to scan the table using the following command.

aws dynamodb scan --table-name <table_name> --region <region_name>

Enter fullscreen mode Exit fullscreen mode

Image description
Benefits:

Scalability: DynamoDB scales automatically to handle any amount of traffic and storage.

Performance: Provides single-digit millisecond latency for read and write operations.

Security: IAM enables granular access control to DynamoDB resources, enhancing security posture.

Conclusion:
Setting up a DynamoDB table and configuring IAM access control ensures your application’s data storage is scalable, performant, and secure. By following best practices in defining table schemas, creating IAM policies, and integrating services, you establish a robust foundation for building cloud-native applications on AWS. This architecture supports modern application requirements with flexibility and resilience in data management.

💖 💪 🙅 🚩
rashmitha_v_d0cfc20ba7152
Rashmitha v

Posted on July 8, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related