Skip to content

Commit

Permalink
Fix error on only updating index.force_destroy.
Browse files Browse the repository at this point in the history
Closes #61
  • Loading branch information
phillbaker committed May 31, 2020
1 parent 19c1ee3 commit bc734d5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions es/resource_elasticsearch_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
14 changes: 14 additions & 0 deletions es/resource_elasticsearch_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
`
)

Expand All @@ -49,6 +57,12 @@ func TestAccElasticsearchIndex(t *testing.T) {
checkElasticsearchIndexUpdated("elasticsearch_index.test"),
),
},
{
Config: testAccElasticsearchIndexUpdateForceDestroy,
Check: resource.ComposeTestCheckFunc(
checkElasticsearchIndexUpdated("elasticsearch_index.test"),
),
},
},
})
}
Expand Down

0 comments on commit bc734d5

Please sign in to comment.