diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2eb11154d..a165ceb63 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,6 +102,7 @@ jobs: - '8.11.4' - '8.12.2' - '8.13.4' + - '8.14.0' steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a78cb7a2..980b5df81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Populate policy_id when importing fleet policies and integrations ([#646](https://github.com/elastic/terraform-provider-elasticstack/pull/646)) - Fix alerting rule update crash when backend responds with HTTP 4xx. ([#649](https://github.com/elastic/terraform-provider-elasticstack/pull/649)) +- Support allow_write_after_shrink when managing ILM policies ([#662](https://github.com/elastic/terraform-provider-elasticstack/pull/662)) ## [0.11.3] - 2024-05-16 diff --git a/docs/resources/elasticsearch_index_lifecycle.md b/docs/resources/elasticsearch_index_lifecycle.md index 380a54b2f..825876dd0 100644 --- a/docs/resources/elasticsearch_index_lifecycle.md +++ b/docs/resources/elasticsearch_index_lifecycle.md @@ -322,6 +322,7 @@ Required: Optional: +- `allow_write_after_shrink` (Boolean) If true, the shrunken index is made writable by removing the write block. - `max_primary_shard_size` (String) The max primary shard size for the target index. - `number_of_shards` (Number) Number of shards to shrink to. @@ -415,6 +416,7 @@ Required: Optional: +- `allow_write_after_shrink` (Boolean) If true, the shrunken index is made writable by removing the write block. - `max_primary_shard_size` (String) The max primary shard size for the target index. - `number_of_shards` (Number) Number of shards to shrink to. diff --git a/internal/elasticsearch/index/ilm.go b/internal/elasticsearch/index/ilm.go index 4ee7b9ec7..536b41a8f 100644 --- a/internal/elasticsearch/index/ilm.go +++ b/internal/elasticsearch/index/ilm.go @@ -355,6 +355,11 @@ var supportedActions = map[string]*schema.Schema{ Type: schema.TypeString, Optional: true, }, + "allow_write_after_shrink": { + Description: "If true, the shrunken index is made writable by removing the write block.", + Type: schema.TypeBool, + Optional: true, + }, }, }, }, @@ -530,7 +535,7 @@ func expandPhase(p map[string]interface{}, serverVersion *version.Version) (*mod case "set_priority": actions[actionName], diags = expandAction(a, serverVersion, "priority") case "shrink": - actions[actionName], diags = expandAction(a, serverVersion, "number_of_shards", "max_primary_shard_size") + actions[actionName], diags = expandAction(a, serverVersion, "number_of_shards", "max_primary_shard_size", "allow_write_after_shrink") case "unfollow": if a[0] != nil { ac := a[0].(map[string]interface{}) @@ -563,14 +568,15 @@ var ilmActionSettingOptions = map[string]struct { def interface{} minVersion *version.Version }{ - "number_of_replicas": {skipEmptyCheck: true}, - "total_shards_per_node": {skipEmptyCheck: true, def: -1, minVersion: version.Must(version.NewVersion("7.16.0"))}, - "priority": {skipEmptyCheck: true}, - "min_age": {def: "", minVersion: RolloverMinConditionsMinSupportedVersion}, - "min_docs": {def: 0, minVersion: RolloverMinConditionsMinSupportedVersion}, - "min_size": {def: "", minVersion: RolloverMinConditionsMinSupportedVersion}, - "min_primary_shard_size": {def: "", minVersion: RolloverMinConditionsMinSupportedVersion}, - "min_primary_shard_docs": {def: 0, minVersion: RolloverMinConditionsMinSupportedVersion}, + "number_of_replicas": {skipEmptyCheck: true}, + "total_shards_per_node": {skipEmptyCheck: true, def: -1, minVersion: version.Must(version.NewVersion("7.16.0"))}, + "priority": {skipEmptyCheck: true}, + "min_age": {def: "", minVersion: RolloverMinConditionsMinSupportedVersion}, + "min_docs": {def: 0, minVersion: RolloverMinConditionsMinSupportedVersion}, + "min_size": {def: "", minVersion: RolloverMinConditionsMinSupportedVersion}, + "min_primary_shard_size": {def: "", minVersion: RolloverMinConditionsMinSupportedVersion}, + "min_primary_shard_docs": {def: 0, minVersion: RolloverMinConditionsMinSupportedVersion}, + "allow_write_after_shrink": {def: false, minVersion: version.Must(version.NewVersion("8.14.0"))}, } func expandAction(a []interface{}, serverVersion *version.Version, settings ...string) (map[string]interface{}, diag.Diagnostics) { diff --git a/internal/elasticsearch/index/ilm_test.go b/internal/elasticsearch/index/ilm_test.go index 177da2195..ffd4f0d21 100644 --- a/internal/elasticsearch/index/ilm_test.go +++ b/internal/elasticsearch/index/ilm_test.go @@ -210,6 +210,9 @@ resource "elasticstack_elasticsearch_index_lifecycle" "test" { }) number_of_replicas = 1 } + shrink { + max_primary_shard_size = "50gb" + } } }