Terraform
To get resources deployed to our RabbitMq instances we use Terraform. The terraform provider used is cyrilgdn/rabbitmq
terraform {
required_providers {
rabbitmq = {
source = "cyrilgdn/rabbitmq"
version = "1.7.0"
}
}
}
On the provider docs you can read about all the configuration options for rabbit mq resources.
Because of problems with the latest version of the provider the current version that works is
1.7.0
Workflow
In our on-prem github repository infrastructure/rabbitmq
we have our rabbitmq terraform configuration. The repository has two subfolders with independant configuration. One for the test cluster and one for production cluster. Changes made to the test
subfolder will be deployed to the test cluster and changes made to the prod
subfolder will be deployed to the production cluster.
Deployment steps for test
- Create a new branch with the new configuration in the
test
subfolder. - Push your changes
- Create a
pull request
againstmain
- A dry-run is made, i.e.
terraform plan
- Inspect the result from the github action.
- Merge to main
Deployment steps for production
- Create a new branch with the new configuration in the
prod
subfolder. - Push your changes
- Create a
pull request
againstmain
- A dry-run is made, i.e.
terraform plan
- Inspect the result from the github action.
- Merge to main
Examples
Deploy a exchange and a queue with a binding.
resource "rabbitmq_exchange" "maximo_integration_exchange" {
name = "maximo.integration.v1.topic"
vhost = "/"
settings {
type = "topic"
durable = true
auto_delete = false
}
}
resource "rabbitmq_queue" "maximo_integration_apollo_queue_wo" {
name = "maximo.integration.apollo.wo.queue"
vhost = "/"
settings {
durable = true
auto_delete = false
arguments = {
"x-queue-type" = "quorum"
}
}
}
resource "rabbitmq_binding" "maximo_integration_apollo_binding_wo" {
source = "maximo.integration.v1.topic"
vhost = "/"
destination = "maximo.integration.apollo.wo.queue"
destination_type = "queue"
routing_key = "maximo.integration.INT121.wo"
depends_on = [rabbitmq_exchange.maximo_integration_exchange, rabbitmq_queue.maximo_integration_apollo_queue_wo]
}
maximo_integration_apollo_queue_wo
,maximo_integration_exchange
andmaximo_integration_apollo_binding_wo
must be unique across your configuration.
Shovels
Deploy a shovel.
resource "rabbitmq_shovel" "quntiq_biztalk_v1_logisticstopic_stage_shovel" {
name = "quintiq.biztalk.v1.logistics.topic.stage.shovel"
vhost = "/"
info {
source_uri = "amqps://shoveluser:${data.vault_generic_secret.rabbitmq_secret.data["shovelpassword"]}@rmq.lomi.lkab.com"
source_queue = "quintiq.biztalk.v1.logistics.topic.stage.shovel.queue"
destination_uri = "amqp:///stage"
destination_exchange = "quintiq.biztalk.v1.logistics.topic"
}
depends_on = [rabbitmq_exchange.stage_quintiq_biztalk_v1_logistics_topic]
}
Secret information such as user and password is fetched from our vault.