Skip to main content

Overview

The RdsInstance construct provisions a managed PostgreSQL database instance with Multi-AZ deployment, encryption, automated backups, and optional read replicas. It suits applications that want predictable performance and cost.

Resource Class

Basic Usage

instanceType takes the bare class.size form (t4g.medium, r6g.large), not the db.-prefixed form. The construct passes the value straight to new InstanceType(...), so a db. prefix produces an invalid instance class.

Configuration Options

Core Properties

Engine Configuration

Instance Configuration

When Fjall provisions a database through an application tier, the instance type defaults vary: t4g.micro (Tinkerer), t4g.small (Lightweight), t4g.large (Standard), r7g.large (Resilient), r6g.xlarge (Enterprise). When using the construct directly, set instanceType explicitly.

Backup and Maintenance

Snapshot Restore

Additional Features

Restoring from Snapshot

Create a new database from an existing RDS snapshot:
Constraints when restoring from a snapshot:
  • The master username is immutable and baked into the snapshot. snapshotUsername must match the original database’s username exactly.
  • The engine version is inherited from the snapshot. A mismatch between the snapshot’s engine version and the infrastructure code causes a CloudFormation failure.
  • The storage size cannot be smaller than the snapshot’s allocated storage.
  • The master password is reset shortly after the restore. Fjall generates a new credentials secret for the restored instance, and CloudFormation applies its password once the instance becomes available (the instance briefly reports resetting-master-credentials). The snapshot-era password stops working at that point — applications must read credentials from the generated secret.
This password reset only applies to restores performed through infrastructure code (snapshotIdentifier). Restores performed through AWS Backup (fjall restore rds) run outside CloudFormation and keep the snapshot-era password — see fjall restore.
You can also add the resource from the CLI with snapshot restore configured:

Instance Types

General Purpose (Burstable)

General Purpose (Standard)

Memory Optimised

Storage Configuration

Auto-scaling Storage

Storage Type

All instances use GP3 storage by default:
  • Baseline: 3,000 IOPS
  • Burst: up to 16,000 IOPS
  • Throughput: 125 MiB/s baseline

Security Features

Encryption

Storage encryption is on by default with a customer-managed KMS key. Performance Insights data is encrypted when Database Insights is enabled.

Network Security

High Availability

Multi-AZ Deployment

Multi-AZ is enabled by default. Set multiAz: false to opt out.
Benefits:
  • Automatic failover (1-2 minutes)
  • Synchronous replication
  • Maintenance without downtime
  • Enhanced durability

RDS Proxy

Enable connection pooling by passing a ProxyConfig object. ProxyConfig fields: requireTLS, maxConnections, maxIdleConnections, connectionBorrowTimeout, vpcSubnets.
Benefits:
  • Reduced database connections
  • Improved application scalability
  • Automatic failover handling
  • IAM authentication support

Read Replicas

Enable a read replica by passing a ReadReplicaConfig object. ReadReplicaConfig fields: instanceType, availabilityZone. Pass {} to inherit the primary’s instance type.
Read replica features:
  • Asynchronous replication
  • Read-only queries
  • Can be promoted to primary
  • Cross-region support

Database Insights

Database Insights (formerly Performance Insights) is enabled by default. Pass a DatabaseInsightsConfig object to set the mode, or false to disable it. DatabaseInsightsConfig fields: mode ("standard" or "advanced"), encryptionKey.
Features:
  • SQL-level performance metrics
  • 7 days retention in standard mode, 15 months in advanced mode
  • Top SQL identification
  • Wait event analysis

Backup and Recovery

Custom Backup Configuration

Automated Backups

  • Daily automated backups
  • Point-in-time recovery
  • Transaction log backups every 5 minutes
  • Backups retained after deletion

Methods

Get Host Endpoint

Get Host Port

Get Credentials

Get Connections

Get Security Group

Complete Example

Cost Optimisation

Instance Sizing

*Estimates for us-east-1, Multi-AZ deployment.

Cost Saving Tips

  1. Use Graviton instances (t4g, r6g, m6g) for up to 20% savings.
  2. Reserved Instances for 1-3 year commitments.
  3. Right-size based on CloudWatch metrics.
  4. Consider Aurora for variable workloads.
  5. Optimise storage size to avoid over-provisioning.

Best Practices

  1. Keep Multi-AZ on for production (default).
  2. Use memory-optimised instance types (r6g) for production.
  3. Monitor storage usage and keep autoscaling on.
  4. Test backups regularly.
  5. Keep encryption on (default).
  6. Set up CloudWatch alarms for key metrics.

Limitations

  • Maximum 64 TB storage.
  • Maximum 40,000 IOPS (GP3).
  • No automatic cross-region failover.
  • Read replicas have replication lag.
  • Maintenance windows cause brief downtime.

Next Steps

RDS Free Tier

Run a free-tier-eligible PostgreSQL instance during your first 12 months.

RDS Aurora

Scale to an Aurora cluster with serverless and global options.

Storage Factory

Provision databases and storage through the Fjall factory pattern.

Secrets Manager

Manage database credentials and rotation.