From f465e55721e31390fc64650c7c7eea517e862234 Mon Sep 17 00:00:00 2001 From: Arie Lev <34907201+ArieLevs@users.noreply.github.com> Date: Tue, 10 Mar 2020 12:20:11 +0200 Subject: [PATCH] Add ASG cooldown and health_check_grace_period (#770) * Add default_cooldown/health_check oprions * Update CHANGELOG.md * Update CHANGELOG.md Co-Authored-By: Thierno IB. BARRY Co-authored-by: Thierno IB. BARRY --- CHANGELOG.md | 1 + local.tf | 2 ++ workers.tf | 10 ++++++++++ workers_launch_template.tf | 10 ++++++++++ 4 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ec8e8..983081f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ project adheres to [Semantic Versioning](http://semver.org/). - Adding `encrypted` option to worker's root_block_device as read from the worker configurations (by @craig-rueda) - Use correct policy arns for CN regions (cn-north-1, cn-northwest-1) (by @cofyc) - Add support for ASG max instance lifetime (by @sidprak) +- Add `default_cooldown` and `health_check_grace_period` options to workers ASG (by @ArieLevs) # History diff --git a/local.tf b/local.tf index e4969f7..1175176 100644 --- a/local.tf +++ b/local.tf @@ -33,6 +33,8 @@ locals { asg_force_delete = false # Enable forced deletion for the autoscaling group. asg_initial_lifecycle_hooks = [] # Initital lifecycle hook for the autoscaling group. asg_recreate_on_change = false # Recreate the autoscaling group when the Launch Template or Launch Configuration change. + default_cooldown = null # The amount of time, in seconds, after a scaling activity completes before another scaling activity can start. + health_check_grace_period = null # Time in seconds after instance comes into service before checking health. instance_type = "m4.large" # Size of the workers instances. spot_price = "" # Cost of spot instance. placement_tenancy = "" # The tenancy of the instance. Valid values are "default" or "dedicated". diff --git a/workers.tf b/workers.tf index a4b9a3c..66a1951 100644 --- a/workers.tf +++ b/workers.tf @@ -78,6 +78,16 @@ resource "aws_autoscaling_group" "workers" { "max_instance_lifetime", local.workers_group_defaults["max_instance_lifetime"], ) + default_cooldown = lookup( + var.worker_groups[count.index], + "default_cooldown", + local.workers_group_defaults["default_cooldown"] + ) + health_check_grace_period = lookup( + var.worker_groups[count.index], + "health_check_grace_period", + local.workers_group_defaults["health_check_grace_period"] + ) dynamic "initial_lifecycle_hook" { for_each = var.worker_create_initial_lifecycle_hooks ? lookup(var.worker_groups[count.index], "asg_initial_lifecycle_hooks", local.workers_group_defaults["asg_initial_lifecycle_hooks"]) : [] diff --git a/workers_launch_template.tf b/workers_launch_template.tf index e3eb2ef..52ec738 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -77,6 +77,16 @@ resource "aws_autoscaling_group" "workers_launch_template" { "max_instance_lifetime", local.workers_group_defaults["max_instance_lifetime"], ) + default_cooldown = lookup( + var.worker_groups_launch_template[count.index], + "default_cooldown", + local.workers_group_defaults["default_cooldown"] + ) + health_check_grace_period = lookup( + var.worker_groups_launch_template[count.index], + "health_check_grace_period", + local.workers_group_defaults["health_check_grace_period"] + ) dynamic mixed_instances_policy { iterator = item