terraform-provider-elasticstack icon indicating copy to clipboard operation
terraform-provider-elasticstack copied to clipboard

[Feature] Support index setting with json format

Open pakio opened this issue 3 years ago • 3 comments

This issue is a feature request to support the JSON format setting definition, as the index mapping definition supports.

I'm trying to use Elasticsearch as our search engine and we have massive amount of analysis settings on the index. But since the current provider doesn't support the json format settings, I needed to write everything in terraform format, which was very hard to read and struggled to convert json formatted data to this specific format.

And I believe this is causing lots of issues like the below.

  • #108
  • #119

I'm more than happy to contribute if this feature looks good to the community. Thanks!

pakio avatar Jul 14 '22 04:07 pakio

@pakio - Apologies if it's a silly question:

Are you not able to define some templates for this as opposed to directly defining the settings for the specific index? it may be a good workaround to use in the meantime. https://github.com/elastic/terraform-provider-elasticstack/blob/main/examples/resources/elasticstack_elasticsearch_index_template/resource.tf - you can define the index template to match your relevant indices. It then accepts the settings and mappings in json format for this resource as opposed to this having to conform to HCL for settings.

Agree that it probably needs updating on the index resource to accept json instead too though!

RobsonSutton avatar Jul 23 '22 14:07 RobsonSutton

Thank you for your comment, @RobsonSutton !

In my use case, we need to update the configuration on the live index, e.g, adding new fields, changing number_of_replicas, and changing the search_analyzer to apply new filters or synonyms. Please correct me if I'm saying wrong, but in my understanding, updating the index template does not update the live index.

pakio avatar Jul 25 '22 01:07 pakio

@pakio - Drat! I was hoping your use case would be a bit more generic, you are completely correct, any updates will only affect a new version of the templates following the approach I mentioned. I'll take a look at whether I can raise something to get this changed directly via the index resource when I have a spare few mins, hopefully it shouldn't be too difficult as the logic can probably just be lifted and shifted from the current template resource (no promises I'll sort it though as I'm still new to Go and general TF provider contributions!) 👍

RobsonSutton avatar Jul 25 '22 08:07 RobsonSutton