Database Insights is an advanced observability feature that provides AI-powered recommendations and deeper performance analysis. It requires Performance Insights to be enabled.Variables
| Variable | Default | Description |
|---|
database_insights_mode | null | Mode of Database Insights. Valid values: standard, advanced. |
Example
module "db" {
source = "terraform-aws-modules/rds/aws"
identifier = "my-db"
# ... engine, instance, storage variables
# Database Insights requires Performance Insights
performance_insights_enabled = true
performance_insights_retention_period = 731
database_insights_mode = "advanced"
# ... other variables
}
advanced mode incurs additional charges and requires an instance class that supports Database Insights. Check the AWS documentation for supported instance classes before enabling advanced mode.
The module can export engine log streams to CloudWatch Logs and optionally create the log groups in Terraform so you can manage their retention and encryption.Variables
| Variable | Default | Description |
|---|
enabled_cloudwatch_logs_exports | [] | Log types to export. Valid values depend on engine (see below). |
create_cloudwatch_log_group | false | Create a CloudWatch log group for each exported log type. |
cloudwatch_log_group_retention_in_days | 7 | Days to retain logs in the created log groups. |
cloudwatch_log_group_kms_key_id | null | KMS key ARN for encrypting log data. |
cloudwatch_log_group_skip_destroy | null | When true, removes the log group from state without deleting it. |
cloudwatch_log_group_class | null | Log group class: STANDARD or INFREQUENT_ACCESS. |
Valid log types by engine
| Engine | Valid export values |
|---|
| MySQL | audit, error, general, slowquery |
| MariaDB | audit, error, general, slowquery |
| PostgreSQL | postgresql, upgrade |
| Oracle | alert, audit, listener, trace |
| SQL Server | agent, error |
MySQL example
module "db" {
source = "terraform-aws-modules/rds/aws"
identifier = "my-mysql"
engine = "mysql"
engine_version = "8.0"
# ...
enabled_cloudwatch_logs_exports = ["general"]
create_cloudwatch_log_group = true
cloudwatch_log_group_retention_in_days = 30
}
PostgreSQL example
module "db" {
source = "terraform-aws-modules/rds/aws"
identifier = "my-postgres"
engine = "postgres"
engine_version = "17"
# ...
enabled_cloudwatch_logs_exports = ["postgresql", "upgrade"]
create_cloudwatch_log_group = true
cloudwatch_log_group_retention_in_days = 7
}
Log groups are created at the path /aws/rds/instance/{identifier}/{log_type}.Log groups are not created when instance_use_identifier_prefix = true, because the final identifier is not known until after the instance is created.