Skip to main content

Overview

The DatabaseFactory creates database resources with type-safe configurations. It supports Aurora (Serverless v2 clusters), RDS instances, Global Aurora, and DynamoDB tables.
For S3 storage buckets, use the StorageFactory instead.

Basic Usage

Database Types

Aurora

Aurora Serverless v2 cluster running PostgreSQL or MySQL:
Features:
  • Serverless v2 writer and optional read replicas
  • Capacity scales automatically with load
  • High availability across Availability Zones
  • Automatic backups with snapshot removal policy

RDS Instance

Traditional database instance for predictable workloads:
Features:
  • Fixed instance size
  • Lower baseline cost for small workloads
  • Free tier eligible (t4g.micro)

Global Aurora

Multi-region database for global applications:
Features:
  • Cross-region replication
  • Low-latency global reads
  • Automatic failover

DynamoDB

Serverless NoSQL database:
Features:
  • Serverless (pay per request)
  • Single-digit millisecond latency
  • Automatic scaling
  • Global tables support

Configuration Parameters

Common Parameters (Relational)

Use databaseEngine for simple string-based configuration. Use engine only when you need to pass a CDK engine object with custom parameters.

Aurora Parameters

Instance Parameters

DynamoDB Parameters

Common Patterns

Production Aurora

Development Database

Cache Table

Session Store

Accessing Database Information

Relational Databases

DynamoDB

Connecting to Compute

Lambda with Database

ECS with Database

Granting Access

Relational Databases

Access is automatically granted when using connections. For manual grants:

DynamoDB

Security

Automatic Security Features

  • Encryption at rest: All databases encrypted by default
  • Encryption in transit: SSL/TLS enforced
  • Secrets Manager: Credentials stored securely
  • VPC isolation: Databases in private subnets
  • Security groups: Automatic least-privilege rules

Database Insights

Best Practices

  1. Use Aurora Serverless for variable workloads
  2. Use Instance for predictable, small workloads
  3. Enable Database Insights in production
  4. Use DynamoDB for key-value and session data
  5. Use connections for automatic IAM and security group setup
  6. Enable deletion protection in production

Next Steps

Storage Factory

Create S3 buckets for file storage

Compute Factory

Deploy Lambda and ECS compute resources

Payload Pattern

Full-stack Payload CMS deployment

Standard Pattern

Production web application pattern