Skip to content

Commit 7f83b65

Browse files
dm3chcloudpossebotgoruha
authored
Added AutoTune support (#149)
* Added AutoTune support * Auto Format * Update variables.tf Co-authored-by: Igor Rodionov <[email protected]> * Update variables.tf Co-authored-by: Igor Rodionov <[email protected]> * Update variables.tf Co-authored-by: Igor Rodionov <[email protected]> * Auto Format * Rework auto_tune variables to single object * Try to fix variables.tf lint * Auto Format * Update variables.tf Co-authored-by: Igor Rodionov <[email protected]> * Update variables.tf Co-authored-by: Igor Rodionov <[email protected]> --------- Co-authored-by: cloudpossebot <[email protected]> Co-authored-by: Igor Rodionov <[email protected]>
1 parent c6e9dfe commit 7f83b65

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ Available targets:
214214
| <a name="input_advanced_security_options_master_user_password"></a> [advanced\_security\_options\_master\_user\_password](#input\_advanced\_security\_options\_master\_user\_password) | Master user password (applicable if advanced\_security\_options\_internal\_user\_database\_enabled set to true) | `string` | `""` | no |
215215
| <a name="input_allowed_cidr_blocks"></a> [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | List of CIDR blocks to be allowed to connect to the cluster | `list(string)` | `[]` | no |
216216
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
217+
| <a name="input_auto_tune"></a> [auto\_tune](#input\_auto\_tune) | This object represents the auto\_tune configuration. It contains the following filed:<br>- enabled - Whether to enable autotune.<br>- rollback\_on\_disable - Whether to roll back to default Auto-Tune settings when disabling Auto-Tune.<br>- starting\_time - Date and time at which to start the Auto-Tune maintenance schedule in RFC3339 format. Time should be in the future.<br>- cron\_schedule - A cron expression specifying the recurrence pattern for an Auto-Tune maintenance schedule.<br>- duration - Autotune maintanance window duration time in hours. | <pre>object({<br> enabled = bool<br> rollback_on_disable = string<br> starting_time = string<br> cron_schedule = string<br> duration = number<br> })</pre> | <pre>{<br> "cron_schedule": null,<br> "duration": null,<br> "enabled": false,<br> "rollback_on_disable": "NO_ROLLBACK",<br> "starting_time": null<br>}</pre> | no |
217218
| <a name="input_automated_snapshot_start_hour"></a> [automated\_snapshot\_start\_hour](#input\_automated\_snapshot\_start\_hour) | Hour at which automated snapshots are taken, in UTC | `number` | `0` | no |
218219
| <a name="input_availability_zone_count"></a> [availability\_zone\_count](#input\_availability\_zone\_count) | Number of Availability Zones for the domain to use. | `number` | `2` | no |
219220
| <a name="input_aws_ec2_service_name"></a> [aws\_ec2\_service\_name](#input\_aws\_ec2\_service\_name) | AWS EC2 Service Name | `list(string)` | <pre>[<br> "ec2.amazonaws.com"<br>]</pre> | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
| <a name="input_advanced_security_options_master_user_password"></a> [advanced\_security\_options\_master\_user\_password](#input\_advanced\_security\_options\_master\_user\_password) | Master user password (applicable if advanced\_security\_options\_internal\_user\_database\_enabled set to true) | `string` | `""` | no |
5252
| <a name="input_allowed_cidr_blocks"></a> [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | List of CIDR blocks to be allowed to connect to the cluster | `list(string)` | `[]` | no |
5353
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
54+
| <a name="input_auto_tune"></a> [auto\_tune](#input\_auto\_tune) | This object represents the auto\_tune configuration. It contains the following filed:<br>- enabled - Whether to enable autotune.<br>- rollback\_on\_disable - Whether to roll back to default Auto-Tune settings when disabling Auto-Tune.<br>- starting\_time - Date and time at which to start the Auto-Tune maintenance schedule in RFC3339 format. Time should be in the future.<br>- cron\_schedule - A cron expression specifying the recurrence pattern for an Auto-Tune maintenance schedule.<br>- duration - Autotune maintanance window duration time in hours. | <pre>object({<br> enabled = bool<br> rollback_on_disable = string<br> starting_time = string<br> cron_schedule = string<br> duration = number<br> })</pre> | <pre>{<br> "cron_schedule": null,<br> "duration": null,<br> "enabled": false,<br> "rollback_on_disable": "NO_ROLLBACK",<br> "starting_time": null<br>}</pre> | no |
5455
| <a name="input_automated_snapshot_start_hour"></a> [automated\_snapshot\_start\_hour](#input\_automated\_snapshot\_start\_hour) | Hour at which automated snapshots are taken, in UTC | `number` | `0` | no |
5556
| <a name="input_availability_zone_count"></a> [availability\_zone\_count](#input\_availability\_zone\_count) | Number of Availability Zones for the domain to use. | `number` | `2` | no |
5657
| <a name="input_aws_ec2_service_name"></a> [aws\_ec2\_service\_name](#input\_aws\_ec2\_service\_name) | AWS EC2 Service Name | `list(string)` | <pre>[<br> "ec2.amazonaws.com"<br>]</pre> | no |

main.tf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,23 @@ resource "aws_elasticsearch_domain" "default" {
159159
}
160160
}
161161

162+
dynamic "auto_tune_options" {
163+
for_each = var.auto_tune.enabled ? [true] : []
164+
content {
165+
desired_state = "ENABLED"
166+
rollback_on_disable = var.auto_tune.rollback_on_disable
167+
maintenance_schedule {
168+
# Required until https://github.com/hashicorp/terraform-provider-aws/issues/22239 would be resolved
169+
start_at = var.auto_tune.starting_time == null ? timeadd(timestamp(), "1h") : var.auto_tune.starting_time
170+
duration {
171+
value = var.auto_tune.duration
172+
unit = "HOURS"
173+
}
174+
cron_expression_for_recurrence = var.auto_tune_cron_schedule
175+
}
176+
}
177+
}
178+
162179
node_to_node_encryption {
163180
enabled = var.node_to_node_encryption_enabled
164181
}
@@ -296,4 +313,4 @@ module "kibana_hostname" {
296313
records = [join("", aws_elasticsearch_domain.default.*.endpoint)]
297314

298315
context = module.this.context
299-
}
316+
}

variables.tf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,45 @@ variable "custom_endpoint_certificate_arn" {
363363
description = "ACM certificate ARN for custom endpoint."
364364
default = ""
365365
}
366+
367+
variable "auto_tune" {
368+
type = object({
369+
enabled = bool
370+
rollback_on_disable = string
371+
starting_time = string
372+
cron_schedule = string
373+
duration = number
374+
})
375+
376+
default = {
377+
enabled = false
378+
rollback_on_disable = "NO_ROLLBACK"
379+
starting_time = null
380+
cron_schedule = null
381+
duration = null
382+
}
383+
384+
description = <<-EOT
385+
This object represents the auto_tune configuration. It contains the following filed:
386+
- enabled - Whether to enable autotune.
387+
- rollback_on_disable - Whether to roll back to default Auto-Tune settings when disabling Auto-Tune.
388+
- starting_time - Date and time at which to start the Auto-Tune maintenance schedule in RFC3339 format. Time should be in the future.
389+
- cron_schedule - A cron expression specifying the recurrence pattern for an Auto-Tune maintenance schedule.
390+
- duration - Autotune maintanance window duration time in hours.
391+
EOT
392+
393+
validation {
394+
condition = var.auto_tune.enabled == false || var.auto_tune.cron_schedule != null
395+
error_message = "Variable auto_tune.cron_schedule should be set if var.auto_tune.enabled == true."
396+
}
397+
398+
validation {
399+
condition = var.auto_tune.enabled == false || var.auto_tune.duration != null
400+
error_message = "Variable auto_tune.duration should be set if var.auto_tune.enabled == true."
401+
}
402+
403+
validation {
404+
condition = contains(["DEFAULT_ROLLBACK", "NO_ROLLBACK"], var.auto_tune.rollback_on_disable)
405+
error_message = "Variable auto_tune.rollback_on_disable valid values: DEFAULT_ROLLBACK or NO_ROLLBACK."
406+
}
407+
}

0 commit comments

Comments
 (0)