-
Notifications
You must be signed in to change notification settings - Fork 79
rabbitmq: bindings not being stored in state #2
Comments
I just debugged a similar issue with bindings not being stored in the state file and here's my findings. According to https://raw.githack.com/rabbitmq/rabbitmq-management/rabbitmq_v3_6_7/priv/www/api/index.html a binding's properties_key in rabbitmq is a combination if its routing key and a hash of the arguments and it separates them with ~. It comes out something like ~U71-Q7rVcYLiGY8sYgmeCQ in our case when we have a blank routing key with arguments supplied. As far as I can tell, whatever you supply in properties_keys isn't actually used in rabbitmq, but is used incorrectly as part of the id in terraform. In https://github.com/terraform-providers/terraform-provider-rabbitmq/blob/master/rabbitmq/resource_binding.go#L85 the properties_key in the template resource is used as part of the id of the binding, but the one supplied in the template is not necessarily what it gets created as. That id is then used again later at https://github.com/terraform-providers/terraform-provider-rabbitmq/blob/master/rabbitmq/resource_binding.go#L99 and then split to compare it against all the bindings returned for a vhost. In this case, everything else matches properly, except properties_key which causes the lookup to fail, and thus return nil and not get stored in the statefile. Some logs and values to backup my findings
Notice how the PropertiesKey is nothing like the one I supplied of SOMEVALUE and how it matches the Location header in the response to the create. If I'm understanding everything correctly, then the solution would be to use the value returned in the Note, I am able to work around this by supplying the generated value I'm going to try to take a minute today to submit a PR assuming the above analysis is right, and you guys like the approach towards fixing it. Thanks. |
@sgarlick987 Thank you for the detailed analysis of this issue. If you submit a PR, I'd be happy to review it. |
Ok sounds good. I have something working now, but need to update tests/docs and then I'll submit. |
This issue was originally opened by @jason-archidera as hashicorp/terraform#12782. It was migrated here as part of the provider split. The original body of the issue is below.
I seem to have an issue and it seems to be in saving state.
Version: 0.9
Resource: rabbitmq_binding
I've setup my project with a main.tf:
My modules folder has several tf files and all is well except for any binding with a routing key that isn't "#". For example:
I run the commands, everything seems to work, except for the bindings with anything other than "#" are not stored in the remote state (Consul). This causes each time I run plan or apply, it thinks these bindings are new.
It's either a bug in the RabbitMQ provider or perhaps in state? The interesting part is that the bindings are created in RabbitMQ, but the state is not saved.
The text was updated successfully, but these errors were encountered: