Review MQ broker logging

Enable operational and audit logs supported by the Amazon MQ engine.

Description

Set logs.general = true to send broker operational logs to CloudWatch Logs. ActiveMQ can also audit management actions through JMX or its web console. RabbitMQ does not support this audit option.

Potential impact

With general logging off, an audit entry may show a management action without the broker events needed to diagnose a connection failure.

Remediation

Grant logs:CreateLogGroup to the IAM identity that creates or reboots the broker and allow Amazon MQ to deliver logs through the CloudWatch Logs resource policy. Set retention and check for a recent broker event.

Examples

Both examples set audit = true. The second enables general logs. Keep the existing broker_name when changing only logging because renaming replaces the broker. The first excerpt omits required inputs. Supply a supported engine and instance type for the Region, the referenced configuration and security group, and a securely managed password. ActiveMQ 5.18 and later requires auto_minor_version_upgrade = true.

Before

hcl
resource "aws_mq_broker" "example" {
  broker_name = "disabled-logging"

  logs {
    general = false
    audit   = true
  }
}

After

hcl
resource "aws_mq_broker" "example" {
  broker_name = "example"

  configuration {
    id       = aws_mq_configuration.test.id
    revision = aws_mq_configuration.test.latest_revision
  }

  engine_type        = "ActiveMQ"
  engine_version     = var.activemq_engine_version
  host_instance_type = var.mq_instance_type
  security_groups    = [aws_security_group.test.id]

  user {
    username = "ExampleUser"
    password = var.broker_password
  }

  logs {
    general = true
    audit   = true
  }
}

References