db_instance submodule is the core of the terraform-aws-rds module. It provisions the aws_db_instance resource along with the Enhanced Monitoring IAM role, CloudWatch log groups, and Secrets Manager password rotation. The root module wraps this submodule and coordinates it with the subnet group, parameter group, and option group submodules.
Source
Usage
To use this submodule directly:In most cases, use the root module (
terraform-aws-modules/rds/aws) rather than this submodule directly. The root module creates and wires together the subnet group, parameter group, and option group automatically.Input variables
Resource control
Resource control
Instance
Instance
string
required
The name of the RDS instance.
bool
Determines whether to use
identifier as-is or create a unique identifier beginning with identifier as the specified prefix.Default: falsestring
The database engine to use. Not required when
replicate_source_db is set.Default: nullstring
The engine version to use.Default:
nullstring
The life cycle type for this DB instance. Applies only to RDS for MySQL and RDS for PostgreSQL. Valid values:
open-source-rds-extended-support, open-source-rds-extended-support-disabled.Default: nullstring
The instance type of the RDS instance (e.g.
db.t3.micro, db.r6g.large).Default: nullnumber
The allocated storage in gigabytes.Default:
nullstring
One of
standard, gp2, gp3, or io1. Defaults to io1 if iops is specified, gp2 otherwise.Default: nullbool
Specifies whether the DB instance is encrypted.Default:
truestring
The ARN for the KMS encryption key.Default:
nullnumber
Enables Storage Autoscaling when set to a value greater than
allocated_storage. Set to 0 to disable.Default: 0number
Storage throughput for
gp3 storage type.Default: nullnumber
The amount of provisioned IOPS. Requires
storage_type of io1 or gp3.Default: nullbool
Use a dedicated log volume (DLV) for the DB instance. Requires Provisioned IOPS.Default:
falsestring
RDS custom IAM instance profile name.Default:
nullDatabase credentials
Database credentials
string
The DB name to create. If omitted, no database is created initially.Default:
nullstring
Username for the master DB user. Ignored when
replicate_source_db is set.Default: nullstring
Write-only, ephemeral password for the master DB user. Not used when
manage_master_user_password is true or replicate_source_db is set.Default: nullnumber
Version counter for
password_wo. Increment to trigger a password update.Default: nullbool
Set to
true to let RDS manage the master user password via Secrets Manager.Default: truestring
KMS key ARN/ID/alias for encrypting the Secrets Manager secret.Default:
nullstring
The port on which the DB accepts connections.Default:
nullNetwork
Network
list(string)
List of VPC security group IDs to associate.Default:
[]string
Name of the DB subnet group for the instance.Default:
nullstring
Name of the DB parameter group to associate.Default:
nullstring
Name of the DB option group to associate.Default:
nullbool
Bool to control if instance is publicly accessible.Default:
falsebool
Specifies if the RDS instance is multi-AZ.Default:
falsestring
The Availability Zone of the RDS instance.Default:
nullstring
The type of network stack to use. Valid values:
IPV4, DUAL.Default: nullbool
Indicates whether to enable a customer-owned IP address (CoIP) for an RDS on Outposts DB instance.Default:
nullBackup & Recovery
Backup & Recovery
number
The days to retain backups for.Default:
nullstring
The daily time range (UTC) during which automated backups are created.Default:
nullbool
On delete, copy all Instance tags to the final snapshot.Default:
truebool
If
true, no final snapshot is created on deletion.Default: falsestring
Prefix for the final snapshot identifier.Default:
"final"bool
Specifies whether to remove automated backups immediately after the DB instance is deleted.Default:
truestring
Snapshot ID from which to create the DB instance.Default:
nullobject
Restore to a point in time. MySQL is not supported. See inputs reference for the full object schema.Default:
nullobject
Restore from a Percona Xtrabackup in S3. Only MySQL is supported. See inputs reference for the full object schema.Default:
nullMaintenance
Maintenance
string
The window to perform maintenance in.Default:
nullbool
Apply database modifications immediately rather than during the next maintenance window.Default:
falsebool
Allow major engine version upgrades.Default:
falsebool
Automatically apply minor engine upgrades during the maintenance window.Default:
trueobject
Enable low-downtime updates using RDS Blue/Green deployments.Default:
nullbool
Upgrade the storage file system configuration on the read replica.Default:
nullMonitoring
Monitoring
number
Enhanced Monitoring collection interval in seconds. Valid values:
0, 1, 5, 10, 15, 30, 60. Use 0 to disable.Default: 0string
ARN of the IAM role for Enhanced Monitoring. Required when
monitoring_interval > 0 and create_monitoring_role = false.Default: nullstring
Name of the IAM role to create for Enhanced Monitoring.Default:
"rds-monitoring-role"bool
Use
monitoring_role_name as a prefix instead of an exact name.Default: falsestring
Description of the monitoring IAM role.Default:
nullbool
Create an IAM role for Enhanced Monitoring.Default:
falsestring
ARN of the permissions boundary policy for the monitoring IAM role.Default:
nullbool
Enable Performance Insights.Default:
falsenumber
Days to retain Performance Insights data. Valid values:
7, 731, or a multiple of 31.Default: 7string
KMS key ARN for encrypting Performance Insights data.Default:
nullstring
Database Insights mode. Valid values:
standard, advanced.Default: nullCloudWatch Logs
CloudWatch Logs
list(string)
Log types to export to CloudWatch Logs.Default:
[]bool
Create CloudWatch log groups for each export type. Not created when
use_identifier_prefix is true.Default: falsenumber
Days to retain CloudWatch logs.Default:
7string
KMS key ARN for encrypting CloudWatch log data.Default:
nullbool
Preserve log groups on destroy.Default:
nullstring
Log group class. Valid values:
STANDARD, INFREQUENT_ACCESS.Default: nullmap(string)
Additional tags for the CloudWatch log group(s).Default:
{}Authentication — Password Rotation
Authentication — Password Rotation
bool
Manage master user password rotation via Secrets Manager. Requires
manage_master_user_password = true.Default: falsebool
Rotate the secret immediately on next apply.Default:
nullnumber
Days between automatic rotations.Default:
nullstring
Length of the rotation window in hours (e.g.
3h).Default: nullstring
cron() or rate() expression for the rotation schedule.Default: nullActive Directory
Active Directory
string
ID of the Directory Service Active Directory domain.Default:
nullstring
ARN of the Secrets Manager secret with Active Directory credentials.Default:
nulllist(string)
IPv4 DNS IPs of Active Directory domain controllers.Default:
nullstring
FQDN of the self-managed Active Directory domain.Default:
nullstring
Name of the IAM role for Directory Service API calls.Default:
nullstring
Active Directory organizational unit for the DB instance.Default:
nullReplicas
Replicas
Database settings
Database settings
string
Character set name for Oracle instances. Cannot be changed after creation.Default:
nullstring
National character set for Oracle NCHAR/NVARCHAR2/NCLOB columns. Cannot be changed after creation.Default:
nullstring
DB instance timezone. Only supported by Microsoft SQL Server.Default:
nullstring
License model for the DB instance. Required for some engines.Default:
nullbool
Enable IAM database authentication.Default:
falsebool
Prevent the instance from being deleted.Default:
falsestring
Identifier of the CA certificate for the DB instance.Default:
nullOutputs
string
The hostname of the RDS instance.
string
The ARN of the RDS instance.
string
The Availability Zone of the RDS instance.
string
The connection endpoint in
address:port format.object
The listener connection endpoint for SQL Server Always On.
string
The database engine.
string
The running version of the database engine.
string
The canonical hosted zone ID of the DB instance.
string
The RDS instance identifier.
string
The RDS Resource ID of this instance.
string
The RDS instance status.
string
The database name.
string
The master username for the database. Sensitive.
number
The database port.
string
The CA certificate identifier.
string
The ID of the Active Directory domain the instance is joined to.
string
The ARN of the Active Directory credentials secret.
list(string)
The DNS IP addresses of the Active Directory domain controllers.
string
The FQDN of the Active Directory domain.
string
The IAM role name used for Directory Service API calls.
string
The Active Directory organizational unit the instance joined.
string
The ARN of the Secrets Manager secret for the master user password.
string
The upgrade rollout order for the instance.
map(object)
Map of CloudWatch log groups created for the DB instance.
bool
Whether automatic Secrets Manager rotation is enabled.
string
The name of the Enhanced Monitoring IAM role.
string
The ARN of the Enhanced Monitoring IAM role.