通过Terraform将定义文件导入AmazonMQ



我已经使用Terraform创建了一个Amazon MQ broker(引擎类型为RabbitMQ(。现在我想导入一个定义文件,它是一个XML。这可以很容易地手动完成,我只需要导出定义文件并手动将其导入AWSMQ。但我需要使用地形使这个过程自动化。任何建议都将不胜感激。那是我的地形代码:

resource "aws_mq_broker" "rabbitmq_broker" {
broker_name         = "mq_test"
engine_type         = var.mq_engine_type
engine_version      = var.mq_engine_version
host_instance_type  = var.mq_instance_type
deployment_mode     = var.mq_deployment_mode
security_groups     = [aws_security_group.ecs_private.id]
apply_immediately   = "true"
publicly_accessible = "false"
subnet_ids          = [aws_subnet.private.id]
user {
console_access = "true"
username       = var.mq_username
password       = "password"
}
tags = {
env         = "${terraform.workspace}",
}
}

首先,您需要创建一个MQ配置,将XML文件传递给它。然后,将配置传递给代理。

resource "aws_mq_configuration" "rabbitmq_broker_config" {
name           = "My Broker Configuration"
description    = "My RabbitMQ Broker Configuration"
engine_type    = var.mq_engine_type
engine_version = var.mq_engine_version
data = file("${path.module}/broker-config.xml")
}
resource "aws_mq_broker" "rabbitmq_broker" {
# All your attributes here

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

相关内容

  • 没有找到相关文章

最新更新