Dynamo Db

Description

DynamoDB is used as a Document DB provider behind the Flex abstraction (IFlexDocumentStore). Generated wiring maps your logical document models to Dynamo tables, and your business logic stays consistent across providers.

Important Concepts

  • Table metadata is config-driven: partition key / sort key and table names are configured.

  • Queries/handlers remain provider-agnostic: you use IFlexDocumentStore.

  • AppContext is mandatory: always call dto.GetAppContext().

Configuration in DI (where to add)

Provider wiring is generated in your Infrastructure project (under a ...DataStoreProviders/Document/DynamoDb folder). You typically do not register individual queries/handlers here — Flex generates and wires those.

If you are wiring DynamoDB manually, add the document-store provider registration where you configure infrastructure services:

// Infrastructure (example)
services.AddFlexDynamoDocumentStore<OrderDocument>(configuration);

appsettings.json

{
	"FlexBase": {
		"DataStores": {
			"Document": {
				"DynamoDb": {
					"Region": "us-east-1",
					"AccessKeyId": "<from-secrets>",
					"SecretAccessKey": "<from-secrets>",
					"TableName": "Orders",
					"PartitionKeyName": "id",
					"UseLocalStack": false,
					"ServiceUrl": null
				}
			}
		}
	}
}

Examples (from the generated templates)

Dynamo uses the same generated shapes as other Document DB providers.

Query example (Get-by-id)

Provider-specific considerations

  • Keys: design your partition/sort keys around your read patterns.

  • Capacity mode: provisioned vs on-demand is an environment choice; keep it in configuration.

  • TTL/Streams: enable TTL for lifecycle cleanup and streams when you need change capture.

Last updated