Launching an DYNAMODB Instance on AWS
Follow these steps to create and launch an DYNAMODB instance on AWS:
🌍 Step 1: Log in & Open DynamoDB
🔹 Go to the AWS Console and sign in.
🔹 In the Search Bar, type DynamoDB and click on it.
🛠️ Step 2: Create a New DynamoDB Table
🔹 Click Create Table.
🔹 Enter a Table Name (e.g., UserData).
🔹 Set a Primary Key:
- Partition Key → e.g., UserID (String or Number)
- (Optional) Sort Key → e.g., Timestamp (For ordered data)
💡 Use a Partition Key only for simple lookups. If you need sorting, add a Sort Key!
🔹 Click Create Table 🎉
🔢 Step 3: Configure Read/Write Capacity
🔹 Choose On-demand mode for auto-scaling (best for new projects 🚀).
🔹 Or select Provisioned to manually control read/write capacity.
📌 Tip: Enable Auto Scaling to optimize costs & performance!
🔗 Step 4: Insert Data into DynamoDB
🔹 Option 1: Manually Add Items
1️⃣ Open the UserData table.
2️⃣ Click Explore Table Items → Create Item.
3️⃣ Add key-value pairs (e.g., UserID = 101, Name = John Doe).
4️⃣ Click Save ✅
🔹 Option 2: Insert Data via AWS CLI
Run this command in the AWS CLI:
bash
CopyEdit
aws dynamodb put-item \
–table-name UserData \
–item ‘{“UserID”: {“N”: “101”}, “Name”: {“S”: “John Doe”}}’ \
–region us-east-1
✅ Your data is now stored in DynamoDB!
📜 Step 5: Query & Retrieve Data
🔹 Use the DynamoDB Query Editor or AWS CLI to fetch data.
🔹 Scan (Fetch All Items):
aws dynamodb scan –table-name UserData –region us-east-1
🔹 Query (Fetch by Key):
aws dynamodb query \
–table-name UserData \
–key-condition-expression “UserID = :id” \
–expression-attribute-values ‘{“:id”:{“N”:”101″}}’ \
–region us-east-1
📌 Use Query for efficient lookups instead of Scan!
🚀 Step 6: Enable Streams & Triggers (Optional)
💡 DynamoDB Streams capture real-time changes!
🔹 Go to DynamoDB Table → Exports and Streams.
🔹 Enable DynamoDB Streams to track data changes.
🔹 Use AWS Lambda to trigger events when data updates.
🔐 Step 7: Secure DynamoDB with IAM Roles
1️⃣ Go to IAM → Policies → Create Policy.
2️⃣ Add this DynamoDB Read-Only Policy:
{
“Version”: “2012-10-17”,
“Statement”: [
{
“Effect”: “Allow”,
“Action”: [
“dynamodb:GetItem”,
“dynamodb:Scan”,
“dynamodb:Query”
],
“Resource”: “arn:aws:dynamodb:us-east-1:123456789012:table/UserData”
}
]
}
3️⃣ Attach the policy to IAM users, roles, or EC2 instances.
✅ Final Check: DynamoDB Setup is Ready!
🎉 You’ve successfully set up DynamoDB with:
✔️ NoSQL table creation
✔️ Auto-scaling for optimized performance
✔️ Efficient querying with Partition & Sort Keys
✔️ Real-time triggers with DynamoDB Streams
✔️ Secure access using IAM Policies