RDSOSMetrics log group and are distinct from the standard CloudWatch metrics available at the instance level.
This example shows how to use an externally created IAM role for enhanced monitoring, demonstrating the monitoring_role_arn approach as an alternative to create_monitoring_role = true.
Configuration
main.tf
monitoring_interval values
The monitoring_interval variable controls how frequently (in seconds) Enhanced Monitoring metrics are sampled and sent to CloudWatch Logs. Valid values are:
Lower intervals provide more granular data but increase the volume of data written to CloudWatch Logs. For most production workloads,
30 or 60 seconds provides sufficient granularity.
When
monitoring_interval is set to any non-zero value, you must supply either monitoring_role_arn (an existing role ARN) or set create_monitoring_role = true (to have the module create the role automatically). Failing to provide a role when monitoring_interval > 0 will result in an apply error.Two approaches to the monitoring IAM role
Option 1: Let the module create the role
Setcreate_monitoring_role = true and optionally customize the role name:
AmazonRDSEnhancedMonitoringRole managed policy and the trust policy for monitoring.rds.amazonaws.com.
Option 2: Bring your own role
Create the IAM role outside the module and pass its ARN viamonitoring_role_arn:
CloudWatch log exports
Theenabled_cloudwatch_logs_exports variable controls which database log types are shipped to CloudWatch Logs. The example exports audit and general logs for MySQL.
Available log types by engine:
When
create_cloudwatch_log_group = true, the module creates a CloudWatch log group for each log type listed in enabled_cloudwatch_logs_exports. The log groups are retained for cloudwatch_log_group_retention_in_days days (default: 7).