Review RDS CloudWatch log exports

Export RDS operational logs to CloudWatch for centralized analysis.

Description

Export the RDS engine logs you need to CloudWatch Logs.

Potential impact

Logs can exist on an instance while still being unavailable for central troubleshooting.

Remediation

In enabled_cloudwatch_logs_exports, select types supported by your database engine. Set the DB parameters needed to produce them and the retention period in CloudWatch. Verify that records arrive.

Examples

The example exports only PostgreSQL upgrade logs. Add postgresql for general database logs, and supply the DB password securely.

Before

hcl
resource "aws_db_instance" "example" {
  allocated_storage = 20
  engine            = "postgres"
  instance_class    = "db.t3.small"
  password          = var.db_password
  username          = "admin"
}

After

hcl
resource "aws_db_instance" "example" {
  allocated_storage = 20
  engine            = "postgres"
  instance_class    = "db.t3.small"
  password          = var.db_password
  username          = "admin"

  enabled_cloudwatch_logs_exports = ["upgrade"]
}

References