From 7bf47366c2e48a3fa92aec3ad54cd2d45304aa87 Mon Sep 17 00:00:00 2001 From: Esteban Barrios Date: Sat, 21 Oct 2023 00:13:49 +0200 Subject: [PATCH] Fix: instance refresh missing properties (#121) * Fix: instance refresh missing properties * Added missing variables to the variables.tf file * Change type to string instead of bool * chore(fmt,readme): updated --------- Co-authored-by: Jeremy White Co-authored-by: Jeremy White --- README.md | 2 +- docs/terraform.md | 2 +- main.tf | 10 ++++++---- variables.tf | 10 ++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 57a07db..6c6092f 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,7 @@ Available targets: | [image\_id](#input\_image\_id) | The EC2 image ID to launch | `string` | `""` | no | | [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Shutdown behavior for the instances. Can be `stop` or `terminate` | `string` | `"terminate"` | no | | [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instances |
object({
market_type = string
spot_options = optional(object({
block_duration_minutes = optional(number)
instance_interruption_behavior = optional(string)
max_price = optional(number)
spot_instance_type = optional(string)
valid_until = optional(string)
}))
})
| `null` | no | -| [instance\_refresh](#input\_instance\_refresh) | The instance refresh definition |
object({
strategy = string
preferences = optional(object({
instance_warmup = optional(number, null)
min_healthy_percentage = optional(number, null)
skip_matching = optional(bool, null)
auto_rollback = optional(bool, null)
}), null)
triggers = optional(list(string), [])
})
| `null` | no | +| [instance\_refresh](#input\_instance\_refresh) | The instance refresh definition |
object({
strategy = string
preferences = optional(object({
instance_warmup = optional(number, null)
min_healthy_percentage = optional(number, null)
skip_matching = optional(bool, null)
auto_rollback = optional(bool, null)
scale_in_protected_instances = optional(string, null)
standby_instances = optional(string, null)
}), null)
triggers = optional(list(string), [])
})
| `null` | no | | [instance\_reuse\_policy](#input\_instance\_reuse\_policy) | If warm pool and this block are configured, instances in the Auto Scaling group can be returned to the warm pool on scale in. The default is to terminate instances in the Auto Scaling group when the group scales in. |
object({
reuse_on_scale_in = bool
})
| `null` | no | | [instance\_type](#input\_instance\_type) | Instance type to launch | `string` | n/a | yes | | [key\_name](#input\_key\_name) | The SSH key name that should be used for the instance | `string` | `""` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 12814f9..d2563ea 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -69,7 +69,7 @@ | [image\_id](#input\_image\_id) | The EC2 image ID to launch | `string` | `""` | no | | [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Shutdown behavior for the instances. Can be `stop` or `terminate` | `string` | `"terminate"` | no | | [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instances |
object({
market_type = string
spot_options = optional(object({
block_duration_minutes = optional(number)
instance_interruption_behavior = optional(string)
max_price = optional(number)
spot_instance_type = optional(string)
valid_until = optional(string)
}))
})
| `null` | no | -| [instance\_refresh](#input\_instance\_refresh) | The instance refresh definition |
object({
strategy = string
preferences = optional(object({
instance_warmup = optional(number, null)
min_healthy_percentage = optional(number, null)
skip_matching = optional(bool, null)
auto_rollback = optional(bool, null)
}), null)
triggers = optional(list(string), [])
})
| `null` | no | +| [instance\_refresh](#input\_instance\_refresh) | The instance refresh definition |
object({
strategy = string
preferences = optional(object({
instance_warmup = optional(number, null)
min_healthy_percentage = optional(number, null)
skip_matching = optional(bool, null)
auto_rollback = optional(bool, null)
scale_in_protected_instances = optional(string, null)
standby_instances = optional(string, null)
}), null)
triggers = optional(list(string), [])
})
| `null` | no | | [instance\_reuse\_policy](#input\_instance\_reuse\_policy) | If warm pool and this block are configured, instances in the Auto Scaling group can be returned to the warm pool on scale in. The default is to terminate instances in the Auto Scaling group when the group scales in. |
object({
reuse_on_scale_in = bool
})
| `null` | no | | [instance\_type](#input\_instance\_type) | Instance type to launch | `string` | n/a | yes | | [key\_name](#input\_key\_name) | The SSH key name that should be used for the instance | `string` | `""` | no | diff --git a/main.tf b/main.tf index be8f314..73e6244 100644 --- a/main.tf +++ b/main.tf @@ -180,10 +180,12 @@ resource "aws_autoscaling_group" "default" { dynamic "preferences" { for_each = instance_refresh.value.preferences != null ? [instance_refresh.value.preferences] : [] content { - instance_warmup = lookup(preferences.value, "instance_warmup", null) - min_healthy_percentage = lookup(preferences.value, "min_healthy_percentage", null) - skip_matching = lookup(preferences.value, "skip_matching", null) - auto_rollback = lookup(preferences.value, "auto_rollback", null) + instance_warmup = lookup(preferences.value, "instance_warmup", null) + min_healthy_percentage = lookup(preferences.value, "min_healthy_percentage", null) + skip_matching = lookup(preferences.value, "skip_matching", null) + auto_rollback = lookup(preferences.value, "auto_rollback", null) + scale_in_protected_instances = lookup(preferences.value, "scale_in_protected_instances", null) + standby_instances = lookup(preferences.value, "standby_instances", null) } } triggers = instance_refresh.value.triggers diff --git a/variables.tf b/variables.tf index 4eca35b..1d66390 100644 --- a/variables.tf +++ b/variables.tf @@ -112,10 +112,12 @@ variable "instance_refresh" { type = object({ strategy = string preferences = optional(object({ - instance_warmup = optional(number, null) - min_healthy_percentage = optional(number, null) - skip_matching = optional(bool, null) - auto_rollback = optional(bool, null) + instance_warmup = optional(number, null) + min_healthy_percentage = optional(number, null) + skip_matching = optional(bool, null) + auto_rollback = optional(bool, null) + scale_in_protected_instances = optional(string, null) + standby_instances = optional(string, null) }), null) triggers = optional(list(string), []) })