diff --git a/CHANGELOG.md b/CHANGELOG.md index 490c7e75..4ffa2514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - Bump terraform plugin sdk to 1.12.0. - Add aws profile authentication option +### Fixed +- Fix error on only updating index.force_destroy. + ## [1.1.1] - 2020-05-09 ### Added - Make ping to elasticsearch during provider config optional diff --git a/es/resource_elasticsearch_index.go b/es/resource_elasticsearch_index.go index 5fe61b2d..e11414ab 100644 --- a/es/resource_elasticsearch_index.go +++ b/es/resource_elasticsearch_index.go @@ -256,6 +256,12 @@ func resourceElasticsearchIndexUpdate(d *schema.ResourceData, meta interface{}) settings[key] = d.Get(key) } } + + // if we're not changing any settings, no-op this function + if len(settings) == 0 { + return resourceElasticsearchIndexRead(d, meta) + } + body := map[string]interface{}{ "settings": settings, } diff --git a/es/resource_elasticsearch_index_test.go b/es/resource_elasticsearch_index_test.go index 3b6ecbcd..f01a0f92 100644 --- a/es/resource_elasticsearch_index_test.go +++ b/es/resource_elasticsearch_index_test.go @@ -28,6 +28,14 @@ resource "elasticsearch_index" "test" { number_of_shards = 1 number_of_replicas = 2 } +` + testAccElasticsearchIndexUpdateForceDestroy = ` +resource "elasticsearch_index" "test" { + name = "terraform-test" + number_of_shards = 1 + number_of_replicas = 2 + force_destroy = true +} ` ) @@ -49,6 +57,12 @@ func TestAccElasticsearchIndex(t *testing.T) { checkElasticsearchIndexUpdated("elasticsearch_index.test"), ), }, + { + Config: testAccElasticsearchIndexUpdateForceDestroy, + Check: resource.ComposeTestCheckFunc( + checkElasticsearchIndexUpdated("elasticsearch_index.test"), + ), + }, }, }) }