-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Describe the bug
Changing mapping_coerce
on an index's mapping will trigger a replace. But the provider tries first to create the index which is not possible as it already exists.
I even tried adding create_before_destroy = false
which is the default terraform behavior but it didn't work as expected.
lifecycle {
create_before_destroy = false
}
To Reproduce
Steps to reproduce the behavior:
- TF configuration used
resource "elasticstack_elasticsearch_index" "index" {
name = "index-one"
mappings = jsonencode({
properties = {
name = {
type = "text"
}
}
})
number_of_shards = 1
number_of_replicas = 1
search_idle_after = "20s"
mapping_coerce = false
}
terraform apply
to create the index- Then change the
mapping_coerce
to true terraform apply
to apply the coerce- The plan will look like this :
Plan: 1 to add, 0 to change, 1 to destroy.
- Then enter
yes
to apply. - Provider will try to create the resource first which causes the error:
elasticstack_elasticsearch_index.index: Creating...
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╷
│ Error: Unable to create index: index
│
│ with elasticstack_elasticsearch_index.index,
│ on ./elastic-search.tf line 3, in resource "elasticstack_elasticsearch_index" "index":
│ 3: resource "elasticstack_elasticsearch_index" "index" {
│
│ Failed with: {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index
│ [index/<ID>] already
│ exists","index_uuid":"<ID>","index":"index"}],"type":"resource_already_exists_exception","reason":"index
│ [index/<ID>] already
│ exists","index_uuid":"<ID>","index":"index"},"status":400}
╵
Expected behavior
The provider should respect create_before_destroy
. In this case it means it has to destroy the index first and then create the new one.
Versions (please complete the following information):
- OS: Mac OS Sequoia 15.1 (24B83)
- Terraform v1.8.5
- Provider version 0.11.12
- Elasticsearch Version 7.17
Additional context
I also tried using alias, had the same result
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working