How to sort key/value pairs in Terraform provider
We use Terraform to deploy our Cloud resources, including registering them with several properties in LogicMonitor. So far so good, until we upgraded the Terraform provider to versie 2.x
Starting version 2 the properties are called custom_properties and need to be presented as key-value pairs. We build the complete array of custom_properties with several variables, so they are not sorted. This works fine on the creation part.
But.... when a LogicMonitor device is created and checked again by Terraform, Terraform wants to change a lot of properties because they look different, which is caused by LogicMonitor presenting them in a sorted order, and not in the way they have been entered.. So every Terraform plan run gives a lot of potential changes which are not changes at all, but it only looks like. This make sidentifying the real changes quite difficult.
I know this might be difficult to understand, but the attached picture might make it more clear:
- Property "shape" is replaced by property "ocid"
- Property "ocid" is replaced by property "tomcat.jmxexports"
- Property "tomcat.jmxexports" is replace by property "shape"
When we have 20+ servers in a run showing this behaviour it is quite confusing :-(
The main question: Is there a way to sort the list with custom_properties, after is is constructed from several variables?
Kind regards,
Jeroen