diff --git a/CHANGELOG.md b/CHANGELOG.md index a248bba..f2ec8e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ project adheres to [Semantic Versioning](http://semver.org/). - Fix doc about spot instances, cluster-autoscaler should be scheduled on normal instances instead of spot (by @simowaer) - 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) # History diff --git a/local.tf b/local.tf index 2151439..e4969f7 100644 --- a/local.tf +++ b/local.tf @@ -79,6 +79,7 @@ locals { spot_allocation_strategy = "lowest-price" # Valid options are 'lowest-price' and 'capacity-optimized'. If 'lowest-price', the Auto Scaling group launches instances using the Spot pools with the lowest price, and evenly allocates your instances across the number of Spot pools. If 'capacity-optimized', the Auto Scaling group launches instances using Spot pools that are optimally chosen based on the available Spot capacity. spot_instance_pools = 10 # "Number of Spot pools per availability zone to allocate capacity. EC2 Auto Scaling selects the cheapest Spot pools and evenly allocates Spot capacity across the number of Spot pools that you specify." spot_max_price = "" # Maximum price per unit hour that the user is willing to pay for the Spot instances. Default is the on-demand price + max_instance_lifetime = 0 # Maximum number of seconds instances can run in the ASG. 0 is unlimited. } workers_group_defaults = merge( diff --git a/workers.tf b/workers.tf index c198c5b..a4b9a3c 100644 --- a/workers.tf +++ b/workers.tf @@ -73,6 +73,11 @@ resource "aws_autoscaling_group" "workers" { "termination_policies", local.workers_group_defaults["termination_policies"] ) + max_instance_lifetime = lookup( + var.worker_groups_launch_template[count.index], + "max_instance_lifetime", + local.workers_group_defaults["max_instance_lifetime"], + ) 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 ba51baa..e3eb2ef 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -72,6 +72,11 @@ resource "aws_autoscaling_group" "workers_launch_template" { "termination_policies", local.workers_group_defaults["termination_policies"] ) + max_instance_lifetime = lookup( + var.worker_groups_launch_template[count.index], + "max_instance_lifetime", + local.workers_group_defaults["max_instance_lifetime"], + ) dynamic mixed_instances_policy { iterator = item