mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-20 16:43:46 +01:00
Support for Mixed Instances ASG in worker_groups_launch_template variable (#468)
* Create ASG tags via for - utility from terraform 12 * Updated support for mixed ASG in worker_groups_launch_template variable * Updated launch_template example to include spot and mixed ASG with worker_groups_launch_template variable * Removed old config * Removed workers_launch_template_mixed.tf file, added support for mixed/spot in workers_launch_template variable * Updated examples/spot_instances/main.tf with Mixed Spot and ondemand instances * Removed launch_template_mixed from relevant files * Updated README.md file * Removed workers_launch_template.tf.bkp * Fixed case with null on_demand_allocation_strategy and Spot allocation * Fixed workers_launch_template.tf, covered spot instances via Launch Template
This commit is contained in:
committed by
Max Williams
parent
a47f464221
commit
461cf5482e
@@ -73,13 +73,81 @@ resource "aws_autoscaling_group" "workers_launch_template" {
|
||||
local.workers_group_defaults["termination_policies"]
|
||||
)
|
||||
|
||||
launch_template {
|
||||
id = aws_launch_template.workers_launch_template.*.id[count.index]
|
||||
version = lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"launch_template_version",
|
||||
local.workers_group_defaults["launch_template_version"],
|
||||
)
|
||||
dynamic mixed_instances_policy {
|
||||
iterator = item
|
||||
for_each = (lookup(var.worker_groups_launch_template[count.index], "override_instance_types", null) != null) || (lookup(var.worker_groups_launch_template[count.index], "on_demand_allocation_strategy", null) != null) ? list(var.worker_groups_launch_template[count.index]) : []
|
||||
|
||||
content {
|
||||
instances_distribution {
|
||||
on_demand_allocation_strategy = lookup(
|
||||
item.value,
|
||||
"on_demand_allocation_strategy",
|
||||
"prioritized",
|
||||
)
|
||||
on_demand_base_capacity = lookup(
|
||||
item.value,
|
||||
"on_demand_base_capacity",
|
||||
local.workers_group_defaults["on_demand_base_capacity"],
|
||||
)
|
||||
on_demand_percentage_above_base_capacity = lookup(
|
||||
item.value,
|
||||
"on_demand_percentage_above_base_capacity",
|
||||
local.workers_group_defaults["on_demand_percentage_above_base_capacity"],
|
||||
)
|
||||
spot_allocation_strategy = lookup(
|
||||
item.value,
|
||||
"spot_allocation_strategy",
|
||||
local.workers_group_defaults["spot_allocation_strategy"],
|
||||
)
|
||||
spot_instance_pools = lookup(
|
||||
item.value,
|
||||
"spot_instance_pools",
|
||||
local.workers_group_defaults["spot_instance_pools"],
|
||||
)
|
||||
spot_max_price = lookup(
|
||||
item.value,
|
||||
"spot_max_price",
|
||||
local.workers_group_defaults["spot_max_price"],
|
||||
)
|
||||
}
|
||||
|
||||
launch_template {
|
||||
launch_template_specification {
|
||||
launch_template_id = aws_launch_template.workers_launch_template.*.id[count.index]
|
||||
version = lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"launch_template_version",
|
||||
local.workers_group_defaults["launch_template_version"],
|
||||
)
|
||||
}
|
||||
|
||||
dynamic "override" {
|
||||
for_each = lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"override_instance_types",
|
||||
local.workers_group_defaults["override_instance_types"]
|
||||
)
|
||||
|
||||
content {
|
||||
instance_type = override.value
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
dynamic launch_template {
|
||||
iterator = item
|
||||
for_each = (lookup(var.worker_groups_launch_template[count.index], "override_instance_types", null) != null) || (lookup(var.worker_groups_launch_template[count.index], "on_demand_allocation_strategy", null) != null) ? [] : list(var.worker_groups_launch_template[count.index])
|
||||
|
||||
content {
|
||||
id = aws_launch_template.workers_launch_template.*.id[count.index]
|
||||
version = lookup(
|
||||
var.worker_groups_launch_template[count.index],
|
||||
"launch_template_version",
|
||||
local.workers_group_defaults["launch_template_version"],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "initial_lifecycle_hook" {
|
||||
|
||||
Reference in New Issue
Block a user