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
The name of the RDS instance.
Determines whether to use
identifier as-is or create a unique identifier beginning with identifier as the specified prefix.Default: falseThe database engine to use. Not required when
replicate_source_db is set.Default: nullThe engine version to use.Default:
nullThe 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: nullThe instance type of the RDS instance (e.g.
db.t3.micro, db.r6g.large).Default: nullThe allocated storage in gigabytes.Default:
nullOne of
standard, gp2, gp3, or io1. Defaults to io1 if iops is specified, gp2 otherwise.Default: nullSpecifies whether the DB instance is encrypted.Default:
trueThe ARN for the KMS encryption key.Default:
nullEnables Storage Autoscaling when set to a value greater than
allocated_storage. Set to 0 to disable.Default: 0Storage throughput for
gp3 storage type.Default: nullThe amount of provisioned IOPS. Requires
storage_type of io1 or gp3.Default: nullUse a dedicated log volume (DLV) for the DB instance. Requires Provisioned IOPS.Default:
falseRDS custom IAM instance profile name.Default:
nullDatabase credentials
Database credentials
The DB name to create. If omitted, no database is created initially.Default:
nullUsername for the master DB user. Ignored when
replicate_source_db is set.Default: nullWrite-only, ephemeral password for the master DB user. Not used when
manage_master_user_password is true or replicate_source_db is set.Default: nullVersion counter for
password_wo. Increment to trigger a password update.Default: nullSet to
true to let RDS manage the master user password via Secrets Manager.Default: trueKMS key ARN/ID/alias for encrypting the Secrets Manager secret.Default:
nullThe port on which the DB accepts connections.Default:
nullNetwork
Network
List of VPC security group IDs to associate.Default:
[]Name of the DB subnet group for the instance.Default:
nullName of the DB parameter group to associate.Default:
nullName of the DB option group to associate.Default:
nullBool to control if instance is publicly accessible.Default:
falseSpecifies if the RDS instance is multi-AZ.Default:
falseThe Availability Zone of the RDS instance.Default:
nullThe type of network stack to use. Valid values:
IPV4, DUAL.Default: nullIndicates whether to enable a customer-owned IP address (CoIP) for an RDS on Outposts DB instance.Default:
nullBackup & Recovery
Backup & Recovery
The days to retain backups for.Default:
nullThe daily time range (UTC) during which automated backups are created.Default:
nullOn delete, copy all Instance tags to the final snapshot.Default:
trueIf
true, no final snapshot is created on deletion.Default: falsePrefix for the final snapshot identifier.Default:
"final"Specifies whether to remove automated backups immediately after the DB instance is deleted.Default:
trueSnapshot ID from which to create the DB instance.Default:
nullRestore to a point in time. MySQL is not supported. See inputs reference for the full object schema.Default:
nullRestore from a Percona Xtrabackup in S3. Only MySQL is supported. See inputs reference for the full object schema.Default:
nullMaintenance
Maintenance
The window to perform maintenance in.Default:
nullApply database modifications immediately rather than during the next maintenance window.Default:
falseAllow major engine version upgrades.Default:
falseAutomatically apply minor engine upgrades during the maintenance window.Default:
trueEnable low-downtime updates using RDS Blue/Green deployments.Default:
nullUpgrade the storage file system configuration on the read replica.Default:
nullMonitoring
Monitoring
Enhanced Monitoring collection interval in seconds. Valid values:
0, 1, 5, 10, 15, 30, 60. Use 0 to disable.Default: 0ARN of the IAM role for Enhanced Monitoring. Required when
monitoring_interval > 0 and create_monitoring_role = false.Default: nullName of the IAM role to create for Enhanced Monitoring.Default:
"rds-monitoring-role"Use
monitoring_role_name as a prefix instead of an exact name.Default: falseDescription of the monitoring IAM role.Default:
nullCreate an IAM role for Enhanced Monitoring.Default:
falseARN of the permissions boundary policy for the monitoring IAM role.Default:
nullEnable Performance Insights.Default:
falseDays to retain Performance Insights data. Valid values:
7, 731, or a multiple of 31.Default: 7KMS key ARN for encrypting Performance Insights data.Default:
nullDatabase Insights mode. Valid values:
standard, advanced.Default: nullCloudWatch Logs
CloudWatch Logs
Log types to export to CloudWatch Logs.Default:
[]Create CloudWatch log groups for each export type. Not created when
use_identifier_prefix is true.Default: falseDays to retain CloudWatch logs.Default:
7KMS key ARN for encrypting CloudWatch log data.Default:
nullPreserve log groups on destroy.Default:
nullLog group class. Valid values:
STANDARD, INFREQUENT_ACCESS.Default: nullAdditional tags for the CloudWatch log group(s).Default:
{}Authentication — Password Rotation
Authentication — Password Rotation
Manage master user password rotation via Secrets Manager. Requires
manage_master_user_password = true.Default: falseRotate the secret immediately on next apply.Default:
nullDays between automatic rotations.Default:
nullLength of the rotation window in hours (e.g.
3h).Default: nullcron() or rate() expression for the rotation schedule.Default: nullActive Directory
Active Directory
ID of the Directory Service Active Directory domain.Default:
nullARN of the Secrets Manager secret with Active Directory credentials.Default:
nullIPv4 DNS IPs of Active Directory domain controllers.Default:
nullFQDN of the self-managed Active Directory domain.Default:
nullName of the IAM role for Directory Service API calls.Default:
nullActive Directory organizational unit for the DB instance.Default:
nullReplicas
Replicas
Database settings
Database settings
Character set name for Oracle instances. Cannot be changed after creation.Default:
nullNational character set for Oracle NCHAR/NVARCHAR2/NCLOB columns. Cannot be changed after creation.Default:
nullDB instance timezone. Only supported by Microsoft SQL Server.Default:
nullLicense model for the DB instance. Required for some engines.Default:
nullEnable IAM database authentication.Default:
falsePrevent the instance from being deleted.Default:
falseIdentifier of the CA certificate for the DB instance.Default:
nullTags & Timeouts
Tags & Timeouts
Outputs
The hostname of the RDS instance.
The ARN of the RDS instance.
The Availability Zone of the RDS instance.
The connection endpoint in
address:port format.The listener connection endpoint for SQL Server Always On.
The database engine.
The running version of the database engine.
The canonical hosted zone ID of the DB instance.
The RDS instance identifier.
The RDS Resource ID of this instance.
The RDS instance status.
The database name.
The master username for the database. Sensitive.
The database port.
The CA certificate identifier.
The ID of the Active Directory domain the instance is joined to.
The ARN of the Active Directory credentials secret.
The DNS IP addresses of the Active Directory domain controllers.
The FQDN of the Active Directory domain.
The IAM role name used for Directory Service API calls.
The Active Directory organizational unit the instance joined.
The ARN of the Secrets Manager secret for the master user password.
The upgrade rollout order for the instance.
Map of CloudWatch log groups created for the DB instance.
Whether automatic Secrets Manager rotation is enabled.
The name of the Enhanced Monitoring IAM role.
The ARN of the Enhanced Monitoring IAM role.