Generate Terraform configuration for AWS RDS PostgreSQL with Multi-AZ, read replicas, and automated backups.
Act as an AWS database architect. Generate Terraform configuration for a production RDS PostgreSQL deployment. ## Input Parameters - **Instance Identifier**: [DB_IDENTIFIER] - **Engine Version**: [PG_VERSION] (15 / 16) - **Instance Class**: [INSTANCE_CLASS] (db.r6g.large / db.r6g.xlarge / etc.) - **Storage**: [STORAGE_GB] GB, Type: [STORAGE_TYPE] (gp3 / io1) - **Read Replica Count**: [REPLICA_COUNT] - **Cross-Region Replica**: [CROSS_REGION] (region name or none) - **VPC ID**: [VPC_ID] ## Terraform Resources 1. **DB Subnet Group** spanning private subnets. 2. **Security Group**: Allow inbound from application SG only on 5432. 3. **Parameter Group**: Optimized settings (shared_buffers, work_mem, max_connections, wal_level for replication). 4. **Option Group** if needed. 5. **Primary RDS Instance**: - Multi-AZ enabled - Encryption at rest with KMS CMK - Performance Insights enabled - Enhanced Monitoring (60s interval) - Automated backups (35 days retention) - Maintenance window - Deletion protection enabled - IAM database authentication 6. **Read Replicas**: Same region, each in different AZ. 7. **Cross-Region Replica** (if specified). 8. **CloudWatch Alarms**: CPU > 80%, free storage < 10GB, replica lag > 30s, connections > 80% max. 9. **SNS Topic** for alarm notifications. 10. **Secrets Manager**: Auto-rotate master password every 30 days. 11. **Proxy** (RDS Proxy) for connection pooling. ## Output Format Return Terraform files: `rds.tf`, `replicas.tf`, `security.tf`, `monitoring.tf`, `variables.tf`, `outputs.tf`. Include connection string output and failover testing commands.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro, Llama 4.
Specify instance class, storage, and replica count based on your workload. Enable cross-region replica for disaster recovery requirements.
Initial release
Sign in and download this prompt to leave a review.