[Bug] ILM Policy set explicitly number of replicas and total_shard_per_node if allocate block is specified
Describe the bug As soon as the ILM policy defines an allocate action, it will explicitly set the number_of_replicas and the total_number_shards even if the default behavior of ILM is to preserve the behavior.
To Reproduce Steps to reproduce the behavior:
- TF configuration used
resource "elasticstack_elasticsearch_index_lifecycle" "bugreproduce" {
name = "bugreproduce"
warm {
min_age = "1d"
allocate {
require = jsonencode({
data = "hot"
})
}
}
}
- TF Plan shows the following output:
+ resource "elasticstack_elasticsearch_index_lifecycle" "bugreproduce" {
+ id = (known after apply)
+ modified_date = (known after apply)
+ name = "bugreproduce"
+ warm {
+ min_age = "1d"
+ allocate {
+ exclude = jsonencode({})
+ include = jsonencode({})
+ number_of_replicas = 0
+ require = jsonencode(
{
+ data = "hot"
}
)
+ total_shards_per_node = -1
}
}
}
- This is the result ilm policy:
{
"version": 1,
"modified_date": "2025-09-02T05:36:53.791Z",
"policy": {
"phases": {
"warm": {
"min_age": "1d",
"actions": {
"allocate": {
"number_of_replicas": 0,
"total_shards_per_node": -1,
"include": {
"box_type": "warm"
},
"exclude": {},
"require": {}
}
}
}
}
},
"in_use_by": {
"indices": [],
"data_streams": [],
"composable_templates": []
}
}
We note that number of replicas and total_shards_per_node are explicitly defined and this overwrite what has been defined in the template after moving the data to the warm phase.
Expected behavior The expectation is that the number of replicas and total shards per node should not be affected if not explicitly specified. In other words, we should not specify default values for these two properties. https://github.com/elastic/terraform-provider-elasticstack/blob/main/internal/elasticsearch/index/ilm.go#L129
Debug output
Screenshots
Versions (please complete the following information):
- OS: MacOS/darwin_arm64
- Terraform Version (OpenTofu v1.10.5) / Terraform v1.5.7
- Provider version v0.11.17
- Elasticsearch Version v8.17.4
Additional context