I’m creating 3-node cluster with CLUSTER_MULTI_AZ deployment mode for RabbitMQ in Terraform Cloud.
my requirement is, i need to use existing VPC and subnets which is created earlier.
resource "aws_mq_broker" "rabbitmq-cloud-test" {
broker_name = var.broker_name
subnet_ids = [
data.terraform_remote_state.global.outputs.private_subnets[0],
data.terraform_remote_state.global.outputs.private_subnets[1],
data.terraform_remote_state.global.outputs.private_subnets[2]
]
engine_type = var.engine_type
engine_version = var.engine_version
host_instance_type = var.host_instance_type
deployment_mode = var.deployment_mode
apply_immediately = var.apply_immediately
auto_minor_version_upgrade = var.auto_minor_version_upgrade
publicly_accessible = var.publicly_accessible
security_groups = [aws_security_group.my_sg.id] ### you will need to create a security group within the same build
user {
username = var.username
password = var.password
}
maintenance_window_start_time {
day_of_week = var.day_of_week
time_of_day = var.time_of_day
time_zone = var.time_zone
}
}
Terraform Cloud AWS Provider Version
Terraform v1.17 Terraform AWS Provider “>= 3.35”
Affected Resource(s)
aws_mq_broker
Expected Behavior:
I was expecting that the broker is created in the given existing VPC and subnets.
Actual Behavior
The issue is hear, Plan of this is successful, but while applying the changes getting below error,
Error: BadRequestException: Subnets must belong to the same VPC. { RespMetadata: { StatusCode: 400, RequestID: “b56b17c8-309f-4457-9eef-734ad6cbcfcc” }, ErrorAttribute: “subnetIds”, Message_: “Subnets must belong to the same VPC.” }
with aws_mq_broker.rabbitmq-cloud-test
on main.tf line 11, in resource “aws_mq_broker” “rabbitmq-cloud-test”:
resource “aws_mq_broker” “rabbitmq-cloud-test” {
Not able to found any suitable resources, any help would be appreciated.