Skip to main content
The 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

bool
Whether to create the DB instance and all associated resources. Set to false to skip all resource creation.Default: true
string
Region where this resource will be managed. Defaults to the region set in the provider configuration.Default: null
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: false
string
The database engine to use. Not required when replicate_source_db is set.Default: null
string
The engine version to use.Default: null
string
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: null
string
The instance type of the RDS instance (e.g. db.t3.micro, db.r6g.large).Default: null
number
The allocated storage in gigabytes.Default: null
string
One of standard, gp2, gp3, or io1. Defaults to io1 if iops is specified, gp2 otherwise.Default: null
bool
Specifies whether the DB instance is encrypted.Default: true
string
The ARN for the KMS encryption key.Default: null
number
Enables Storage Autoscaling when set to a value greater than allocated_storage. Set to 0 to disable.Default: 0
number
Storage throughput for gp3 storage type.Default: null
number
The amount of provisioned IOPS. Requires storage_type of io1 or gp3.Default: null
bool
Use a dedicated log volume (DLV) for the DB instance. Requires Provisioned IOPS.Default: false
string
RDS custom IAM instance profile name.Default: null
string
The DB name to create. If omitted, no database is created initially.Default: null
string
Username for the master DB user. Ignored when replicate_source_db is set.Default: null
string
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: null
number
Version counter for password_wo. Increment to trigger a password update.Default: null
bool
Set to true to let RDS manage the master user password via Secrets Manager.Default: true
string
KMS key ARN/ID/alias for encrypting the Secrets Manager secret.Default: null
string
The port on which the DB accepts connections.Default: null
list(string)
List of VPC security group IDs to associate.Default: []
string
Name of the DB subnet group for the instance.Default: null
string
Name of the DB parameter group to associate.Default: null
string
Name of the DB option group to associate.Default: null
bool
Bool to control if instance is publicly accessible.Default: false
bool
Specifies if the RDS instance is multi-AZ.Default: false
string
The Availability Zone of the RDS instance.Default: null
string
The type of network stack to use. Valid values: IPV4, DUAL.Default: null
bool
Indicates whether to enable a customer-owned IP address (CoIP) for an RDS on Outposts DB instance.Default: null
number
The days to retain backups for.Default: null
string
The daily time range (UTC) during which automated backups are created.Default: null
bool
On delete, copy all Instance tags to the final snapshot.Default: true
bool
If true, no final snapshot is created on deletion.Default: false
string
Prefix for the final snapshot identifier.Default: "final"
bool
Specifies whether to remove automated backups immediately after the DB instance is deleted.Default: true
string
Snapshot ID from which to create the DB instance.Default: null
object
Restore to a point in time. MySQL is not supported. See inputs reference for the full object schema.Default: null
object
Restore from a Percona Xtrabackup in S3. Only MySQL is supported. See inputs reference for the full object schema.Default: null
string
The window to perform maintenance in.Default: null
bool
Apply database modifications immediately rather than during the next maintenance window.Default: false
bool
Allow major engine version upgrades.Default: false
bool
Automatically apply minor engine upgrades during the maintenance window.Default: true
object
Enable low-downtime updates using RDS Blue/Green deployments.Default: null
bool
Upgrade the storage file system configuration on the read replica.Default: null
number
Enhanced Monitoring collection interval in seconds. Valid values: 0, 1, 5, 10, 15, 30, 60. Use 0 to disable.Default: 0
string
ARN of the IAM role for Enhanced Monitoring. Required when monitoring_interval > 0 and create_monitoring_role = false.Default: null
string
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: false
string
Description of the monitoring IAM role.Default: null
bool
Create an IAM role for Enhanced Monitoring.Default: false
string
ARN of the permissions boundary policy for the monitoring IAM role.Default: null
bool
Enable Performance Insights.Default: false
number
Days to retain Performance Insights data. Valid values: 7, 731, or a multiple of 31.Default: 7
string
KMS key ARN for encrypting Performance Insights data.Default: null
string
Database Insights mode. Valid values: standard, advanced.Default: null
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: false
number
Days to retain CloudWatch logs.Default: 7
string
KMS key ARN for encrypting CloudWatch log data.Default: null
bool
Preserve log groups on destroy.Default: null
string
Log group class. Valid values: STANDARD, INFREQUENT_ACCESS.Default: null
map(string)
Additional tags for the CloudWatch log group(s).Default: {}
bool
Manage master user password rotation via Secrets Manager. Requires manage_master_user_password = true.Default: false
bool
Rotate the secret immediately on next apply.Default: null
number
Days between automatic rotations.Default: null
string
Length of the rotation window in hours (e.g. 3h).Default: null
string
cron() or rate() expression for the rotation schedule.Default: null
string
ID of the Directory Service Active Directory domain.Default: null
string
ARN of the Secrets Manager secret with Active Directory credentials.Default: null
list(string)
IPv4 DNS IPs of Active Directory domain controllers.Default: null
string
FQDN of the self-managed Active Directory domain.Default: null
string
Name of the IAM role for Directory Service API calls.Default: null
string
Active Directory organizational unit for the DB instance.Default: null
string
Identifier of the source DB instance to replicate.Default: null
string
Oracle replica mode. Valid values: mounted, open-read-only.Default: null
string
Character set name for Oracle instances. Cannot be changed after creation.Default: null
string
National character set for Oracle NCHAR/NVARCHAR2/NCLOB columns. Cannot be changed after creation.Default: null
string
DB instance timezone. Only supported by Microsoft SQL Server.Default: null
string
License model for the DB instance. Required for some engines.Default: null
bool
Enable IAM database authentication.Default: false
bool
Prevent the instance from being deleted.Default: false
string
Identifier of the CA certificate for the DB instance.Default: null
map(string)
Tags to assign to all resources.Default: {}
map(string)
Additional tags for the DB instance only.Default: {}
object
Terraform resource management timeouts for aws_db_instance. Supports create, update, and delete keys with duration strings (e.g. 40m).Default: null

Outputs

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.