Skip to main content

What this module does

The terraform-aws-rds module creates and manages Amazon RDS database instances on AWS. It wraps the aws_db_instance resource and the supporting resources it depends on — subnet groups, parameter groups, option groups, and monitoring roles — into a single, opinionated module with production-safe defaults. Storage encryption is enabled by default. Master passwords are managed by AWS Secrets Manager by default. A final snapshot is created on deletion by default. These defaults are intentional and reflect how a production RDS instance should be configured.
This module does not create RDS security groups. Use the terraform-aws-security-group module to create the security group and pass its ID via vpc_security_group_ids.

Supported database engines

The module supports all RDS database engines:

Key capabilities

Storage encryption

storage_encrypted defaults to true. Bring your own KMS key with kms_key_id, or use the AWS-managed default key.

Multi-AZ

Set multi_az = true to deploy a standby replica in a second Availability Zone for automatic failover.

Blue/Green deployments

Enable blue_green_update for low-downtime engine version upgrades and schema changes without a maintenance window.

Secrets Manager passwords

manage_master_user_password defaults to true. RDS generates and stores the master password in Secrets Manager and rotates it automatically.

Enhanced Monitoring

Set monitoring_interval to a non-zero value (1–60 seconds) and create_monitoring_role = true to enable OS-level metrics in CloudWatch.

Performance Insights

Set performance_insights_enabled = true to enable query-level performance analysis. Data is retained for 7 days by default.

Read replicas

Pass replicate_source_db with the source instance identifier or ARN to create a read replica, including cross-region replicas.

Storage autoscaling

Set max_allocated_storage above allocated_storage to allow RDS to automatically increase storage as usage grows.

Submodules

The root module is composed of five submodules. Each submodule can also be called independently if you only need to manage part of the infrastructure. For PostgreSQL, db_option_group is never created because PostgreSQL does not support option groups. The module handles this automatically.

Requirements

Declare these in your root module’s versions.tf:
versions.tf

Next steps

See the quickstart to deploy a working RDS instance with a complete MySQL or PostgreSQL example.