I am trying to provision Amazon MQ broker through terraform. I have written code for multi AZ deployment with deployment type is ACTIVE_STANDBY_MULTI_AZ. Now I want to provision the MQ broker in Test environment with SINGLE_INSTANCE deployment type. hence I parameterized the deployment_mode field and passing the values in variables.
this is my variables list:
variable "enviroment" {
default = "test"
}
variable "mq_multiAZ" {
default = "SINGLE_INSTANCE"
}
The below code is absolutely working fine when I replaced the variable (mq_multiAZ) value to "ACTIVE_STANDBY_MULTI_AZ". however, it is not working with variable value "SINGLE_INSTANCE". also note- We require 2 subnets for "ACTIVE_STANDBY_MULTI_AZ" deployments, we can't mention single subnet to work "SINGLE_INSTANCE" deployment.
mq_broker.tf:
resource "aws_mq_broker" "mymq_broker" {
broker_name = "${var.enviroment}-broker"
engine_type = "ActiveMQ"
engine_version = "5.15.9"
host_instance_type = "mq.t2.micro"
deployment_mode = "${var.mq_multiAZ}"
publicly_accessible = false
apply_immediately = false
security_groups = [aws_security_group.amazon_mq.id]
subnet_ids = [
data.aws_subnet.AppSubnetA.id,
data.aws_subnet.AppSubnetB.id,
]
user {
username = "${var.mq_master_user}"
password = "${var.mq_master_pwd}"
console_access = true
}
logs {
general = true
}
maintenance_window_start_time {
day_of_week = "SUNDAY"
time_of_day = "02:00"
time_zone = "UTC"
}
tags = {
Environment = "${var.enviroment}"
Name = "${var.enviroment}-broker"
}
}
The error I am getting for "SINGLE_INSTANCE" deployment:
Error: BadRequestException: Specify a single subnet in [SINGLE_INSTANCE] deployment mode.
{
RespMetadata: {
StatusCode: 400,
RequestID: "716aafdf-578a-4eb7-bfe4-f0f08998b6db"
},
ErrorAttribute: "subnetIds",
Message_: "Specify a single subnet in [SINGLE_INSTANCE] deployment mode."
}
with aws_mq_broker.empays_broker,
on amazonMQ.tf line 1, in resource "aws_mq_broker" "empays_broker":
1: resource "aws_mq_broker" "empays_broker" {