Skip to content

[Bug] elasticstack_elasticsearch_index_lifecycle fails when set_priority is 0 #88

@ghost

Description

Describe the bug
For elasticstack_elasticsearch_index_lifecycle resource, provider fails when the set_priority action is used and the priority value is set to 0. Values such as 1, 50, 100 do work as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new elasticstack_elasticsearch_index_lifecycle resource
  2. In any lifecycle stage, add {set_priority { priority = 0 }}
  3. Apply

Expected behavior
According to documentation, index priority must be zero or greater. Transmit null in the API call to remove the setting from the ILM policy.

Debug output

input

provider "elasticstack" {
  elasticsearch {
    insecure = true
  }
}

resource "elasticstack_elasticsearch_index_lifecycle" "priority_test" {
    name = "priority_test"

    hot {
        min_age = "0ms"

        set_priority {
          priority = 0
        }

        rollover {
          max_age = "30d"
          max_primary_shard_size = "50gb"
          max_docs = 0
        }
    }

}

error message

│ Error: Unable to create or update the ILM policy
│
│   with elasticstack_elasticsearch_index_lifecycle.priority_test,
│   on ilm_import.tf line 7, in resource "elasticstack_elasticsearch_index_lifecycle" "priority_test":
│    7: resource "elasticstack_elasticsearch_index_lifecycle" "priority_test" {
│
│ Failed with: {"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:133] [actions] failed to parse field [set_priority]"}],"type":"x_content_parse_exception","reason":"[1:133]
│ [put_lifecycle_request] failed to parse field [policy]","caused_by":{"type":"x_content_parse_exception","reason":"[1:133] [lifecycle_policy] failed to parse field
│ [phases]","caused_by":{"type":"x_content_parse_exception","reason":"[1:133] [phases] failed to parse field [hot]","caused_by":{"type":"x_content_parse_exception","reason":"[1:133] [phase] failed to parse
│ field [actions]","caused_by":{"type":"x_content_parse_exception","reason":"[1:133] [actions] failed to parse field [set_priority]","caused_by":{"type":"illegal_argument_exception","reason":"Required
│ [priority]"}}}}}},"status":400}
╵

Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • OS: Windows AMD64
  • Terraform Version v1.1.5
  • Provider version v0.3.2
  • Elasticsearch Version v7.16.3

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

ElasticsearchElasticsearch related APIsbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions