Resource: aws_mq_broker

Provides an Amazon MQ broker resource. This resources also manages users for the broker.

Example Usage

Basic Example

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     = "5.17.6"
  host_instance_type = "mq.t2.micro"
  security_groups    = [aws_security_group.test.id]

  user {
    username = "ExampleUser"
    password = "MindTheGap"
  }
}

High-throughput Optimized Example

This example shows the use of EBS storage for high-throughput optimized performance.

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     = "5.17.6"
  storage_type       = "ebs"
  host_instance_type = "mq.m5.large"
  security_groups    = [aws_security_group.test.id]

  user {
    username = "ExampleUser"
    password = "MindTheGap"
  }
}

Cross-Region Data Replication

resource "aws_mq_broker" "example_primary" {
  # primary broker configured in an alternate region
  provider = awsalternate

  apply_immediately  = true
  broker_name        = "example_primary"
  engine_type        = "ActiveMQ"
  engine_version     = "5.17.6"
  host_instance_type = "mq.m5.large"
  security_groups    = [aws_security_group.example_primary.id]
  deployment_mode    = "ACTIVE_STANDBY_MULTI_AZ"

  user {
    username = "ExampleUser"
    password = "MindTheGap"
  }
  user {
    username         = "ExampleReplicationUser"
    password         = "Example12345"
    replication_user = true
  }
}

resource "aws_mq_broker" "example" {
  apply_immediately  = true
  broker_name        = "example"
  engine_type        = "ActiveMQ"
  engine_version     = "5.17.6"
  host_instance_type = "mq.m5.large"
  security_groups    = [aws_security_group.example.id]
  deployment_mode    = "ACTIVE_STANDBY_MULTI_AZ"

  data_replication_mode               = "CRDR"
  data_replication_primary_broker_arn = aws_mq_broker.primary.arn

  user {
    username = "ExampleUser"
    password = "MindTheGap"
  }
  user {
    username         = "ExampleReplicationUser"
    password         = "Example12345"
    replication_user = true
  }
}

See the AWS MQ documentation on cross-region data replication for additional details.

Argument Reference

The following arguments are required:

The following arguments are optional:

configuration

The following arguments are optional:

encryption_options

The following arguments are optional:

ldap_server_metadata

The following arguments are optional:

logs

The following arguments are optional:

maintenance_window_start_time

The following arguments are required:

user

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import MQ Brokers using their broker id. For example:

import {
  to = aws_mq_broker.example
  id = "a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc"
}

Using terraform import, import MQ Brokers using their broker id. For example:

% terraform import aws_mq_broker.example a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc