DatabaseFactory.build
Interface
| Prop | Type | Required | Notes |
|---|---|---|---|
type | "Aurora" | "Instance" | "FreeTier" | Yes | Select Aurora Serverless, RDS Instance or RDS Free Tier |
databaseName | string | Yes | Logical name & identifier prefix |
vpc | IVpc | — | Custom VPC (required for Aurora) |
instanceType | string | — | Instance size (e.g., “t4g.small”, “r6g.large”) |
engine | DatabaseInstanceEngine | — | Database engine and version |
multiAz | boolean | — | Enable Multi-AZ deployment |
publiclyAccessible | boolean | — | Allow public access |
tags | object | — | Extra resource tags |
Storage Types
Aurora Serverless
Serverless Aurora v2 with auto-scaling capacity:- Aurora Serverless v2
- 1 writer, 2 readers
- Built-in RDS Proxy
- Auto-scaling capacity
- High availability
RDS Instance
Traditional RDS instance with configurable engine:- PostgreSQL 17.5 (default)
- r6g.large instance type (default)
- Multi-AZ enabled by default
- Optional RDS Proxy
- Optional read replicas
Free Tier
Cost-free development database:- t3.micro / db.t3.micro instance
- Single-AZ
- Eligible for 750 hours/month free
Example – Free-tier MySQL
Access helpers
The returnedDatabase construct exposes helper methods:
getCredentials()→Secret- AWS Secrets Manager secret with database credentialsgetHostEndpoint()→string- Database host endpointgetHostPort()→string | number- Database portgetDatabaseName()→string- Database nameconnections→IConnectable- For security group connections
Integration with Compute
Pass database credentials and connection info to containers:Best Practices
- Free Tier for Development: Use Free Tier type for dev environments to stay within AWS free tier limits
- Aurora for Production: Use Aurora Serverless for production workloads requiring high availability and auto-scaling
- Secret Management: Always use
containerSecretsImportto inject credentials, never hardcode in environment variables - Connection Arrays: Pass database to
connectionsarray in compute for automatic security group configuration - Multi-AZ: Enable Multi-AZ for production Instance deployments
See Also
- Compute Factory - Connect compute resources to databases
- Network Config - Configure VPC for database deployment