RabbitMQ - Remove Binding using Terraform

This assumes you have setup Terraform as described in RabbitMQ - Getting Started with Terraform. Let's say you have the following files on your Terraform server.

/usr/local/terraform/main.tf
/usr/local/terraform/foo/required_provider.tf
/usr/local/terraform/foo/bindings.tf
/usr/local/terraform/foo/exchanges.tf
/usr/local/terraform/foo/policies.tf
/usr/local/terraform/foo/queues.tf
/usr/local/terraform/foo/shovels.tf
/usr/local/terraform/foo/vhosts.tf

 

Let's say you have created a binding between foo.queue and foo.exchange using Terraform. In this scenario, your bindings.tf would contain something like this.

resource "rabbitmq_binding" "binding1" {
  vhost = "foo"
  source = "foo.exchange"
  destination = "foo.queue"
  destination_type = "queue"
  routing_key = "foo.key"
}

 

To remove the binding, you would remove the binding block from your bindings.tf file. Or, remove the bindings.tf file.

Then, issue the following command to destroy the binding.

terraform apply

 

Something like this should be displayed, and you will be prompted to enter yes.

Terraform will perform the following actions:

  # rabbitmq_binding.binding1 will be destroyed
  - resource "rabbitmq_binding" "binding1" {
      - arguments        = {} -> null
      - destination      = "foo.queue" -> null
      - destination_type = "queue" -> null
      - id               = "foo/foo.exchange/foo.queue/queue/foo.key" -> null
      - properties_key   = "foo.key" -> null
      - routing_key      = "foo.key" -> null
      - source           = "foo.exchange" -> null
      - vhost            = "foo" -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

 

After entering yes, the following should be displayed.

rabbitmq_binding.binding1: Destroying... [id=foo/foo.exchange/foo.queue/queue/foo.key]
rabbitmq_binding.binding1: Destruction complete after 1s

Apply complete! Resources: 0 added, 0 changed, 1 destroyed.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 26e96 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |