Day 55: Dynamic Database in AWS โ€“ DynamoDB

๐Ÿง  What is DynamoDB?

Amazon DynamoDB is a fully managed, serverless, key-value and document NoSQL database designed for single-digit millisecond performance at any scale.


โš™๏ธ Why DynamoDB for DevOps?

โœ… Fully Managed โ€“ No server provisioning or patching
โœ… Highly Scalable โ€“ Auto scaling of throughput & storage
โœ… Serverless โ€“ Integrates easily with AWS Lambda, API Gateway, etc.
โœ… Event-Driven โ€“ Triggers via DynamoDB Streams for CI/CD workflows
โœ… Secure โ€“ Encryption, IAM policies, fine-grained access control


๐Ÿงฑ DynamoDB Core Concepts

TermDescription
TableCollection of data (like a collection in MongoDB)
ItemEquivalent of a row in SQL
AttributeEquivalent of a column in SQL
Primary KeyUniquely identifies each item (can be a partition key or composite key)
ThroughputRead/Write capacity units
Global TablesReplicate tables across AWS regions

๐Ÿ› ๏ธ How to Create a DynamoDB Table (via AWS CLI)

aws dynamodb create-table \
    --table-name DevOpsProjects \
    --attribute-definitions AttributeName=ProjectID,AttributeType=S \
    --key-schema AttributeName=ProjectID,KeyType=HASH \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

๐Ÿ“ This creates a table DevOpsProjects with ProjectID as the partition key.


๐Ÿ“ฅ Insert Data into DynamoDB

aws dynamodb put-item \
  --table-name DevOpsProjects \
  --item '{
    "ProjectID": {"S": "day55"},
    "Name": {"S": "DynamoDB Setup"},
    "Status": {"S": "Completed"}
  }'

๐Ÿ“ค Read Data

aws dynamodb get-item \
  --table-name DevOpsProjects \
  --key '{"ProjectID": {"S": "day55"}}'

๐Ÿ”„ Use Case in DevOps

  • Store deployment metadata for builds

  • Log automation job results

  • Track application configurations

  • Session storage for stateless apps

  • Manage feature flags or user preferences


๐Ÿงช Optional: Enable Streams

DynamoDB Streams allow you to trigger AWS Lambda functions on data changes:

aws dynamodb update-table \
  --table-name DevOpsProjects \
  --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES

๐Ÿ” Security with IAM

You can create fine-grained access policies to control:

  • Table read/write

  • Specific items by partition key

  • Conditional access


๐Ÿ“ฆ Summary

FeatureAvailable in DynamoDB
Serverlessโœ… Yes
Auto Scalingโœ… Yes
Backup & Restoreโœ… Yes
Real-Time Triggersโœ… Yes (via Streams)
Global Tablesโœ… Yes
JSON-like Structureโœ… Yes
0
Subscribe to my newsletter

Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shaharyar Shakir
Shaharyar Shakir