From 5273eadfe45816ab0e19afff1a98b990ab52eb74 Mon Sep 17 00:00:00 2001 From: Sergiu Plotnicu <33776238+sppwf@users.noreply.github.com> Date: Tue, 20 Apr 2021 00:05:06 +0300 Subject: [PATCH] feat: Add support for ASG Warm Pools (#1310) --- local.tf | 1 + workers.tf | 10 ++++++++++ workers_launch_template.tf | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/local.tf b/local.tf index 40927623163..924f9d79e00 100644 --- a/local.tf +++ b/local.tf @@ -71,6 +71,7 @@ locals { termination_policies = [] # A list of policies to decide how the instances in the auto scale group should be terminated. platform = "linux" # Platform of workers. either "linux" or "windows" additional_ebs_volumes = [] # A list of additional volumes to be attached to the instances on this Auto Scaling group. Each volume should be an object with the following: block_device_name (required), volume_size, volume_type, iops, encrypted, kms_key_id (only on launch-template), delete_on_termination. Optional values are grabbed from root volume or from defaults + warm_pool = null # If this block is configured, add a Warm Pool to the specified Auto Scaling group. # Settings for launch templates root_block_device_name = data.aws_ami.eks_worker.root_device_name # Root device name for workers. If non is provided, will assume default AMI was used. root_kms_key_id = "" # The KMS key to use when encrypting the root storage device diff --git a/workers.tf b/workers.tf index 98bc327ef80..9f5ee7bd2c4 100644 --- a/workers.tf +++ b/workers.tf @@ -112,6 +112,16 @@ resource "aws_autoscaling_group" "workers" { } } + dynamic "warm_pool" { + for_each = lookup(var.worker_groups[count.index], "warm_pool", null) != null ? [lookup(var.worker_groups[count.index], "warm_pool")] : [] + + content { + pool_state = lookup(warm_pool.value, "pool_state", null) + min_size = lookup(warm_pool.value, "min_size", null) + max_group_prepared_capacity = lookup(warm_pool.value, "max_group_prepared_capacity", null) + } + } + dynamic "tag" { for_each = concat( [ diff --git a/workers_launch_template.tf b/workers_launch_template.tf index bdf07afd7b1..a7b5f62a40c 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -189,6 +189,16 @@ resource "aws_autoscaling_group" "workers_launch_template" { } } + dynamic "warm_pool" { + for_each = lookup(var.worker_groups_launch_template[count.index], "warm_pool", null) != null ? [lookup(var.worker_groups_launch_template[count.index], "warm_pool")] : [] + + content { + pool_state = lookup(warm_pool.value, "pool_state", null) + min_size = lookup(warm_pool.value, "min_size", null) + max_group_prepared_capacity = lookup(warm_pool.value, "max_group_prepared_capacity", null) + } + } + dynamic "tag" { for_each = concat( [