From 6974a5e1582a4ed2d8b1f9a07cdacd156ba5ffef Mon Sep 17 00:00:00 2001 From: dtscssap <146767262+dtscssap@users.noreply.github.com> Date: Sat, 12 Oct 2024 12:57:19 -0400 Subject: [PATCH] feat: Add support for `desired_capacity_type` (named `desired_size_type`) on self-managed node group (#3166) * set desired_capacity_type * fix: Add variable with `null` type and pass through node group --------- Co-authored-by: Bryant Biggs --- modules/self-managed-node-group/README.md | 1 + modules/self-managed-node-group/main.tf | 1 + modules/self-managed-node-group/variables.tf | 6 ++++++ node_groups.tf | 1 + 4 files changed, 9 insertions(+) diff --git a/modules/self-managed-node-group/README.md b/modules/self-managed-node-group/README.md index 81d58579dd..7b9ffc5a8b 100644 --- a/modules/self-managed-node-group/README.md +++ b/modules/self-managed-node-group/README.md @@ -117,6 +117,7 @@ module "self_managed_node_group" { | [default\_instance\_warmup](#input\_default\_instance\_warmup) | Amount of time, in seconds, until a newly launched instance can contribute to the Amazon CloudWatch metrics. This delay lets an instance finish initializing before Amazon EC2 Auto Scaling aggregates instance metrics, resulting in more reliable usage data | `number` | `null` | no | | [delete\_timeout](#input\_delete\_timeout) | Delete timeout to wait for destroying autoscaling group | `string` | `null` | no | | [desired\_size](#input\_desired\_size) | The number of Amazon EC2 instances that should be running in the autoscaling group | `number` | `1` | no | +| [desired\_size\_type](#input\_desired\_size\_type) | The unit of measurement for the value specified for `desired_size`. Supported for attribute-based instance type selection only. Valid values: `units`, `vcpu`, `memory-mib` | `string` | `null` | no | | [disable\_api\_termination](#input\_disable\_api\_termination) | If true, enables EC2 instance termination protection | `bool` | `null` | no | | [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `null` | no | | [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `any` | `{}` | no | diff --git a/modules/self-managed-node-group/main.tf b/modules/self-managed-node-group/main.tf index 77ca1856c8..127591081b 100644 --- a/modules/self-managed-node-group/main.tf +++ b/modules/self-managed-node-group/main.tf @@ -502,6 +502,7 @@ resource "aws_autoscaling_group" "this" { default_cooldown = var.default_cooldown default_instance_warmup = var.default_instance_warmup desired_capacity = var.desired_size + desired_capacity_type = var.desired_size_type enabled_metrics = var.enabled_metrics force_delete = var.force_delete force_delete_warm_pool = var.force_delete_warm_pool diff --git a/modules/self-managed-node-group/variables.tf b/modules/self-managed-node-group/variables.tf index 92121ea750..fd2216d300 100644 --- a/modules/self-managed-node-group/variables.tf +++ b/modules/self-managed-node-group/variables.tf @@ -420,6 +420,12 @@ variable "desired_size" { default = 1 } +variable "desired_size_type" { + description = "The unit of measurement for the value specified for `desired_size`. Supported for attribute-based instance type selection only. Valid values: `units`, `vcpu`, `memory-mib`" + type = string + default = null +} + variable "ignore_failed_scaling_activities" { description = "Whether to ignore failed Auto Scaling scaling activities while waiting for capacity." type = bool diff --git a/node_groups.tf b/node_groups.tf index de75fc9133..4ac638100a 100644 --- a/node_groups.tf +++ b/node_groups.tf @@ -435,6 +435,7 @@ module "self_managed_node_group" { min_size = try(each.value.min_size, var.self_managed_node_group_defaults.min_size, 0) max_size = try(each.value.max_size, var.self_managed_node_group_defaults.max_size, 3) desired_size = try(each.value.desired_size, var.self_managed_node_group_defaults.desired_size, 1) + desired_size_type = try(each.value.desired_size_type, var.self_managed_node_group_defaults.desired_size_type, null) capacity_rebalance = try(each.value.capacity_rebalance, var.self_managed_node_group_defaults.capacity_rebalance, null) min_elb_capacity = try(each.value.min_elb_capacity, var.self_managed_node_group_defaults.min_elb_capacity, null) wait_for_elb_capacity = try(each.value.wait_for_elb_capacity, var.self_managed_node_group_defaults.wait_for_elb_capacity, null)