Aurora Serverless PostgreSQL Architecture
Overview
This architecture documentation describes the CloudFormation stack that deploys an Aurora Serverless PostgreSQL cluster on AWS. Aurora Serverless is an on-demand, auto-scaling configuration for Amazon Aurora that automatically starts up, shuts down, and scales capacity up or down based on your application's needs.
Key Benefits
- Cost Optimization: Only pay for the database resources you consume, with automatic pause after inactivity
- Auto-Scaling: Seamlessly scales compute capacity from 2 to 4 ACU (Aurora Capacity Units)
- High Availability: Built on Aurora's proven architecture with automatic failover
- Data API: HTTP endpoint for running SQL statements without managing connections
- Fully Managed: No server provisioning or management required
Architecture Diagram
CloudFormation Stack
Infrastructure as Code Deployment
Environment Configuration
devtemporalMahiraScaling Configuration
2 ACU4 ACU300sAWS Secrets Manager
Securely stores and retrieves database credentials (username and password) for the RDS cluster. Referenced dynamically during stack deployment.
Key Parameters:
Aurora Serverless PostgreSQL Cluster
Fully managed, auto-scaling PostgreSQL-compatible database that automatically adjusts capacity based on application needs. Supports Data API for HTTP-based queries.
Key Parameters:
Auto-Scaling
Automatically scales capacity from 2 to 4 ACU based on workload demands
Auto-Pause
Pauses after 5 minutes of inactivity to reduce costs
Security
Encrypted at rest with automatic 30-day backup retention
Stack Outputs
Connection Information
- • Endpoint: DBCluster.Endpoint.Address
- • Port: 5432
- • Database: temporal
Resource Names
- • Cluster ID: dev-AuroraCluster
- • Stack Name: Exported for reference
Components
1. AWS CloudFormation
The infrastructure is defined as code using CloudFormation templates, enabling:
- Version-controlled infrastructure
- Repeatable deployments across environments
- Automated resource provisioning and updates
- Consistent configuration management
2. AWS Secrets Manager
Securely manages database credentials with:
- Encrypted storage of sensitive information
- Dynamic reference resolution during stack deployment
- Automatic rotation capabilities (optional)
- Access control via IAM policies
The template references secrets using the syntax:
!Sub '{{resolve:secretsmanager:$\{DBMaster\}:SecretString:username\}}'
3. Aurora Serverless PostgreSQL Cluster
The core database component with the following characteristics:
Engine Configuration
- Engine: aurora-postgresql
- Engine Mode: serverless
- Engine Version: PostgreSQL 13.9
- Compatible with: PostgreSQL wire protocol
Scaling Configuration
- Minimum Capacity: 2 ACU (Aurora Capacity Units)
- Maximum Capacity: 4 ACU
- Auto-Pause: Enabled (pauses after 300 seconds of inactivity)
- Resume: Automatically resumes when accessed
Security Features
- Storage Encryption: Enabled (at rest)
- In-Transit Encryption: Enabled by default
- Backup Retention: 30 days
- Network Isolation: Deployed in VPC (when NetworkStackName is configured)
Data API
- HTTP Endpoint: Enabled
- Use Cases: Serverless applications, Lambda functions, containerized apps
- Benefits: No persistent database connections required
Configuration
Parameters
The CloudFormation template accepts the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
EnvironmentName | String | dev | Environment identifier (dev/staging/uat/production) |
NetworkStackName | String | 30 | Reference to VPC/network stack |
DBMaster | String | Mahira | Secrets Manager secret name for credentials |
DatabaseName | String | temporal | Initial database name to create |
DBBackupRetentionPeriod | Number | 30 | Days to retain automated backups (1-35) |
EnableDataApi | String | true | Enable HTTP Data API endpoint |
AutoPause | String | true | Enable automatic pause during inactivity |
MaxCapacity | Number | 4 | Maximum ACU for scaling (2-384) |
MinCapacity | Number | 2 | Minimum ACU for scaling (2-384) |
SecondsUntilAutoPause | Number | 300 | Idle time before auto-pause (1-86400) |
EngineVersion | String | 13.9 | PostgreSQL engine version |
Outputs
The stack exports the following outputs for use by other stacks:
- StackName: The CloudFormation stack name
- ClusterName: The Aurora cluster identifier (
dev-AuroraCluster) - DNSName: The cluster endpoint address for connections
- DBName: The database name (
temporal) - DBPort: The PostgreSQL port (
5432)
Deployment
Prerequisites
- AWS Account with appropriate permissions
- Secrets Manager Secret created with database credentials:
{ "username": "your_master_username", "password": "your_secure_password" } - VPC Configuration (if using NetworkStackName parameter)
Deployment Steps
Using AWS CLI
aws cloudformation create-stack \
--stack-name aurora-serverless-dev \
--template-body file://aurora-serverless-postgres.yaml \
--parameters \
ParameterKey=EnvironmentName,ParameterValue=dev \
ParameterKey=DBMaster,ParameterValue=Mahira \
ParameterKey=DatabaseName,ParameterValue=temporal \
--capabilities CAPABILITY_IAM
Using AWS Console
- Navigate to CloudFormation in AWS Console
- Click Create Stack → With new resources
- Upload the
aurora-serverless-postgres.yamltemplate - Configure parameters as needed
- Review and create the stack
Post-Deployment
After successful deployment:
-
Retrieve Connection Details:
aws cloudformation describe-stacks \ --stack-name aurora-serverless-dev \ --query 'Stacks[0].Outputs' -
Test Connection (when cluster is active):
psql -h <DNSName> -p 5432 -U <username> -d temporal -
Using Data API (from Lambda or application):
const AWS = require('aws-sdk'); const rdsDataService = new AWS.RDSDataService(); const params = { resourceArn: 'arn:aws:rds:region:account:cluster:dev-auroracluster', secretArn: 'arn:aws:secretsmanager:region:account:secret:Mahira', database: 'temporal', sql: 'SELECT version();' }; const result = await rdsDataService.executeStatement(params).promise();
Cost Optimization Tips
- Set appropriate auto-pause duration based on usage patterns
- Use Data API to avoid connection management overhead
- Monitor scaling metrics to optimize min/max capacity
- Enable Aurora Serverless v2 for finer-grained scaling (requires template update)
- Review backup retention period based on compliance requirements
Monitoring
Key metrics to monitor:
- ServerlessDatabaseCapacity: Current ACU allocation
- DatabaseConnections: Active connection count
- CPUUtilization: Processor usage percentage
- FreeableMemory: Available RAM
- NetworkThroughput: Data transfer rates
Access metrics via CloudWatch dashboard or AWS Console RDS section.
Related Resources
- Aurora Databases API — Create and list databases per client with region selection via API.
- Amazon Aurora User Guide
- Aurora Serverless v1 Documentation
- RDS Data API Documentation
- CloudFormation RDS Resource Reference