Overview
The RDS Instance resource provides a managed PostgreSQL database instance with flexible configuration options for production workloads. Unlike Aurora Serverless, it uses provisioned compute with predictable pricing and performance. It includes Multi-AZ deployment for high availability, optional RDS Proxy for connection pooling, and integrated AWS Secrets Manager for credential management. RDS Instance is ideal for:- Applications requiring predictable performance and costs
- Workloads with steady, consistent traffic patterns
- Legacy applications requiring specific PostgreSQL versions
- Scenarios where Aurora features are not needed
- Cost-sensitive production workloads with known capacity needs
- PostgreSQL 17.5 latest engine version
- Multi-AZ deployment for automatic failover
- Optional RDS Proxy for connection pooling (disabled by default)
- Optional read replicas for scaling reads
- Automatic credential rotation every 30 days via Secrets Manager
- Optional Performance Insights for monitoring
- Customer-managed KMS encryption for storage
- 14-day backup retention with automated backups
Resource Class
Basic Usage
Configuration Options
Core Properties
| Property | Type | Description | Default |
|---|---|---|---|
vpc | IVpc | VPC for database deployment (required) | - |
databaseName | string | Database name | "postgres" |
engine | IInstanceEngine | PostgreSQL engine version | PostgreSQL 17.5 |
instanceType | InstanceType | Instance size | r6g.large |
port | number | Database port | 5432 |
securityGroupIds | string[] | Existing security group IDs | Auto-created |
Storage Configuration
| Property | Type | Description | Default |
|---|---|---|---|
allocatedStorage | number | Initial storage in GB | 100 |
maxAllocatedStorage | number | Maximum auto-scaled storage | 500 |
Backup Configuration
| Property | Type | Description | Default |
|---|---|---|---|
backupRetention | Duration | Backup retention period | Duration.days(14) |
High Availability
| Property | Type | Description | Default |
|---|---|---|---|
multiAz | boolean | Enable Multi-AZ | true |
Monitoring Configuration
| Property | Type | Description | Default |
|---|---|---|---|
monitoringInterval | Duration | Enhanced monitoring interval | Duration.minutes(1) |
enablePerformanceInsights | boolean | Enable Performance Insights | false |
Optional Features
| Property | Type | Description | Default |
|---|---|---|---|
databaseProxy | boolean | Enable RDS Proxy | false |
readReplica | boolean | Create read replica | false |
Default Configuration
The RDS Instance construct includes these defaults:- PostgreSQL 17.5 latest stable version
- r6g.large instance type (2 vCPU, 16 GB RAM)
- Multi-AZ enabled for high availability
- 100 GB initial storage, auto-scales to 500 GB
- Customer-managed KMS encryption for storage
- Auto-rotating credentials every 30 days
- 14-day backup retention
- Enhanced monitoring every 1 minute
- No RDS Proxy (opt-in feature)
- No read replicas (opt-in feature)
- No Performance Insights (opt-in feature)
Usage Patterns
Pattern 1: Basic Production Instance
Pattern 2: With RDS Proxy and Read Replica
Pattern 3: Cost-Optimized Development
Pattern 4: Custom Security Groups
Integration Examples
With ECS Services
With Lambda Functions
With Application Load Balancer
RDS Proxy Configuration
When to Enable RDS Proxy
Enable RDS Proxy when you have:- Lambda functions (prevent connection exhaustion)
- Container workloads with frequent scaling
- Applications with many short-lived connections
- Need for faster failover recovery
Without RDS Proxy
Read Replica Configuration
Enabling Read Replicas
Using Read Replicas
Storage Configuration
Storage Auto-Scaling
Storage Types
Security Configuration
Network Isolation
Encryption at Rest
Access Credentials
Performance Configuration
Instance Sizing
Performance Insights
Cost Optimization
Instance Type Selection
Multi-AZ Costs
Storage Optimization
Methods
getHostEndpoint()
getHostPort()
getCredentials()
Complete Example
Best Practices
- Enable Multi-AZ for production - automatic failover ensures high availability
- Use RDS Proxy with Lambda - prevents connection exhaustion from function scaling
- Right-size instance types - start with appropriate sizing, avoid over-provisioning
- Enable read replicas for read-heavy workloads - offload queries from primary
- Configure storage auto-scaling - prevents storage full incidents
- Use Performance Insights for optimization - identify slow queries and bottlenecks
- Implement connection pooling in applications - reduce database connection overhead
- Schedule maintenance windows - perform updates during low-traffic periods
- Monitor key metrics - CPU, storage, connections, replication lag
- Use Secrets Manager integration - automatic credential rotation enhances security
Common Patterns
Development, Staging, Production
Microservices with Shared Database
Read-Write Splitting
Cost Considerations
| Component | Cost | Optimization |
|---|---|---|
| Instance (r6g.large) | ~130/month) | Use t4g for dev, right-size production |
| Multi-AZ | 2x instance cost | Disable for non-production |
| Storage (gp3) | $0.08/GB-month | Start small, enable auto-scaling |
| RDS Proxy | ~$11/month | Only enable when needed |
| Read Replica | Full instance cost | Only for read-heavy workloads |
| Backups | Free up to DB size | Reduce retention for dev |
| Performance Insights | Free (7-day retention) | Extended retention adds cost |
| KMS Keys | $1/month per key | 1-2 keys created automatically |
- Development: ~$50-100 (t4g.medium, single-AZ, no extras)
- Production: ~$300-600 (r6g.large, Multi-AZ, proxy)
- Enterprise: ~$1000+ (r6g.xlarge+, Multi-AZ, proxy, replica, insights)
Troubleshooting
Common Issues
-
Connection refused
- Cause: Security group blocks traffic, wrong endpoint
- Solution: Verify security group rules allow port 5432 from application
-
Storage full
- Cause: Auto-scaling not enabled, reached max storage
- Solution: Enable auto-scaling, increase maxAllocatedStorage
-
High CPU utilization
- Cause: Under-sized instance, inefficient queries
- Solution: Scale instance type, optimize queries with Performance Insights
-
Slow queries
- Cause: Missing indexes, table locks, parameter tuning
- Solution: Analyze with Performance Insights, add indexes, adjust parameters
-
Failover delay
- Cause: Multi-AZ failover process
- Solution: Enable RDS Proxy for 66% faster failover
-
Replication lag (read replica)
- Cause: High write volume, network latency
- Solution: Scale primary instance, reduce write frequency
Debug Commands
SQL Diagnostics
Related Resources
- RDS Aurora - Aurora Serverless v2 for variable workloads
- RDS Free Tier - Free tier eligible RDS for development
- VPC - Network configuration
- Security Group - Network access controls
- Secrets Manager - Credential management
- ECS Cluster - Container orchestration
- Lambda Function - Serverless compute