phillbaker / terraform-provider-elasticsearch

An elasticsearch provider for terraform
https://registry.terraform.io/providers/phillbaker/elasticsearch
Mozilla Public License 2.0
303 stars 133 forks source link

Normalize JSON when doing comparison for mappings, etc. #362

Open subsetpark opened 7 months ago

subsetpark commented 7 months ago

Here's a TF plan that I'm currently getting:

  # module.es-prod-22-search.elasticsearch_index.block[1] must be replaced
-/+ resource "elasticsearch_index" "block" {
     ...
      ~ id                                     = "block-deleted-1" -> (known after apply)
      ~ mappings                               = jsonencode( # whitespace changes force replacement
            {
                _routing   = {
                    required = true
                }
...

That is, it suggests that even though the json value of my index mappings hasn't changed at all, the whitespace that I input is not identical to the whitespace in the ES cluster.

I've done some googling about this, and most reports seem to say something like "it's the responsibility of the provider" to ignore whitespace when comparing to the value on the state.

Some citations:

Is this somethat that can be fixed in this provider? Because of this spurious change, we're not able to make any live changes to our cluster.