Overview
TheRdsAurora construct creates an Aurora Serverless v2 PostgreSQL cluster with a writer, one reader, automated backups, and storage encryption.
RDS Proxy connection pooling, customer-managed KMS keys, and scheduled secret rotation are opt-in.
Resource Class
Basic Usage
Configuration Options
Core Properties
The port default comes from
ENGINE_DEFAULT_DATABASE_PORTS in @fjall/generator. Keep it unless you have a reason to move: RDS Proxy accepts client connections only on the engine default, so a custom port behind a proxy makes getHostPort() report the proxy port, not the cluster port, and synth emits a warning explaining the split.
Engine Configuration
The construct pins Aurora PostgreSQL
18.4. That pin moves with construct releases, so treat the version here as indicative and read rdsAurora.ts for the current value. engineVersion is only read to validate the auto-pause floor, so pass it whenever you set serverlessV2MinCapacity: 0.
Serverless v2 Capacity
Synth rejects a min capacity above the max, an auto-pause duration outside 5 minutes to 24 hours, and
serverlessV2MinCapacity: 0 on an engineVersion below 16.3.
Writer Configuration
AuroraWriterConfig accepts enableDatabaseInsights, identifierSuffix, and availabilityZone.
Reader Configuration
Set
count for identical readers or instances for per-reader configuration. The two are mutually exclusive. The first reader scales with the writer. Pass false for a cluster with no readers.
Proxy Configuration
ProxyConfig fields: requireTLS (default true), connectionBorrowTimeout in seconds (default 120), maxConnections and maxIdleConnections as percentages of the cluster maximum, and vpcSubnets (default private with egress).
Backup and Maintenance
RemovalPolicy.SNAPSHOT takes a final snapshot on delete. DESTROY is for disposable-data clusters only: the delete takes the data with it, with no snapshot and no recovery.
Tags are copied to every automated and manual snapshot.
Security
IAM database authentication is enabled on every cluster.
Snapshot Restore
Database Insights
DatabaseInsightsConfig accepts mode ("standard" or "advanced", default "standard") and encryptionKey.
Alarms
Alarms are created only when
alertsTopic is supplied.
Default Architecture
Passing nothing butvpc and databaseName creates:
- 1 writer instance (Serverless v2)
- 1 reader instance (Serverless v2, scaling with the writer)
- Storage encryption with the AWS-managed KMS key
aws/rds - Database Insights in standard mode
- 14-day automated backups, tags copied to snapshots
- Deletion protection on, removal policy
SNAPSHOT - IAM database authentication
proxy configuration to enable it.
Secret rotation is not enabled by default. Opt in with credentials: { secretRotation: {} } for the 30-day default, or { automaticallyAfterDays: 7 } to shorten it.
Encryption
Storage encryption is always on. By default the cluster uses the AWS-managed KMS keyaws/rds, which you cannot rotate, scope, or revoke yourself.
Pass the USE_CMK marker to create a Fjall-managed customer-managed key instead.
IKey in place of USE_CMK.
The storage key is created with protects: "outlives-stack", because the SNAPSHOT removal policy leaves a final snapshot behind and destroying its key would make that snapshot permanently unrestorable.
Network Security
The cluster is placed in private subnets with egress. Its security group starts closed, so grant access explicitly.allowVpcAccess: true to open the database port to the entire VPC CIDR, which avoids cross-stack cyclic dependencies with Lambda.
Reader Configuration
Default (1 reader)
Multiple readers
Per-reader configuration
No readers
Scale to Zero
SetserverlessV2MinCapacity: 0 with an auto-pause duration to let an idle cluster pause and bill nothing for compute. This needs Aurora PostgreSQL 16.3 or later, and you must pass engineVersion so synth can check the floor.
enableDataApi: true when the workload can run DDL over HTTPS instead of holding a VPC connection.
RDS Proxy
Enable RDS Proxy for connection pooling, faster failover, and fewer database connections.maxConnections and maxIdleConnections are percentages of the cluster’s connection limit, not absolute counts.
Enabling the proxy repoints database.connections at the proxy security group, so existing allowDefaultPortFrom grants keep working. Without a proxy, getHostEndpoint() returns the cluster writer endpoint.
Restoring from Snapshot
Create a new Aurora cluster from an existing cluster snapshot.This password reset applies only 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.Backup and Recovery
Custom backup retention
Point-in-time recovery
Aurora supports PITR for any point within the backup retention window:- Continuous backup to S3
- Restore to any second within the retention window
- Cross-region backup replication available
Monitoring
Enhanced monitoring
Database Insights
Enabled on every instance by default in standard mode. It reports:- SQL-level performance metrics
- Top SQL statements
- Database load by wait event
databaseInsights: { mode: "advanced" } for longer retention, or databaseInsights: false to turn it off.
Methods
database.connections is a public Connections property, not a method. Use it for security-group grants.
Complete Example
Cost Optimisation
Serverless v2 bills per ACU-second, so cost tracks the capacity floor you set rather than an instance size.
Figures are us-east-1 list price for compute only. Storage, I/O, backups beyond the free allowance, and RDS Proxy are billed separately, and prices vary by region.
Three levers matter most:
- Set
serverlessV2MinCapacitydeliberately. The floor is what you pay when idle. - Use auto-pause for development and preview clusters.
- Drop readers you do not query, using
readers: falseor a lowercount.
Best Practices
- Enable RDS Proxy when the application opens many short-lived connections.
- Grant access with
allowDefaultPortFromrather than a hardcoded port. - Pass
encryption: { storageKey: USE_CMK }when you need a key you can rotate and revoke. - Match
backupRetentionto your recovery objective (default 14 days). - Route analytics and reporting queries at readers.
- Watch ACU usage and tune the capacity floor.
- Keep
deletionProtectionand theSNAPSHOTremoval policy on for production.
Limitations
- The capacity floor is 0.5 ACU unless auto-pause is enabled (
serverlessV2MinCapacity: 0), which requires Aurora PostgreSQL16.3or later. - Auto-pause duration must be between 5 minutes and 24 hours.
- RDS Proxy accepts client connections only on the engine default port. AWS does not allow configuring the proxy listener port.
- The engine is pinned to Aurora PostgreSQL 18.4. Major version upgrades need planning.
- Cross-region replicas need a Global Database. See
RdsAuroraGlobal. - Changing the storage encryption key after creation replaces the cluster.
Next Steps
RDS Instance
Deploy a single-instance PostgreSQL or MySQL database when you do not need Serverless v2 scaling.
Database Factory
Provision Aurora, RDS Instance, DynamoDB, or ClickHouse from one declarative factory.
Security Group
Control which services and CIDRs can reach the cluster on port 5432.
KMS Key
Create and scope the customer-managed key that encrypts cluster storage.
Secrets Manager
Read the generated database credentials and configure rotation.
fjall restore
Restore an Aurora cluster from an AWS Backup recovery point.