Skip to main content
Marcel Krčah

DynamoDB: key technical concepts & features

Published on , in , ,

This week I attended a knowledge sharing session about the DynamoDB. I knew Dynamo's basics concepts—I used different key-value NoSQL db before, such as Redis, MongoDb or HBase. But I was curious about the technical details of DynamoDb because this has been new territory for me. So here's what I've learned:

Thanks a lot to Evgeny for sharing most of these tips.

Side note on knowledge sharing sessions #

I'm discovering more and more that I enjoy knowledge-sharing sessions. I learned a lot in a very short time (it's effective), I can ask questions (it's interactive), I can discuss the topic with others (it's collaborative). The same applies when I host a session: I can solidify my knowledge, discover gaps, and discuss the topic with others.

CloudFormation example #

Here's an example of a Dynamo table provisioned via CloudFormation Serverless template. The template provisions a table called charging_sessions with an attribute start_date set as a simple primary key. The table is configured with provisioned capacity units. The template also contains an example Lambda function that accesses the Dynamo table.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

ChargeSessionsTable:
	Type: AWS::DynamoDB::Table
	Properties:
		TableName: 'charge_sessions'
		AttributeDefinitions:
		  - AttributeName: 'start_date'
		AttributeType: 'N'   # type Number
		KeySchema:
		  - AttributeName: 'start_date'
			KeyType: 'HASH'  # simple primary key
		ProvisionedThroughput:
		  ReadCapacityUnits: 10
		  WriteCapacityUnits: 10

AddChargeSessionLambda:
	Type: AWS::Serverless::Function
	Environment:
		Variables:
			CHARGE_SESSION_DDB_TABLE: !Ref ChargeSessionsTable
	Policies:
		- DynamoDBCrudPolicy:
			TableName: !Ref ChargeSessionsTable
	# Properties, CodeUri, etc...

This blog is written by Marcel Krcah, an independent consultant for product-oriented software engineering. If you like what you read, sign up for my newsletter