1
0
mirror of https://github.com/terraform-aws-modules/terraform-aws-eks.git synced 2025-09-09 19:32:58 +08:00

add option to recreate ASG when LT or LC changes (#465)

This commit is contained in:
Thierno IB. BARRY
2019-08-20 15:43:18 +02:00
committed by Max Williams
parent 5636447de6
commit d8ed7d0b66
6 changed files with 92 additions and 13 deletions
+30 -5
View File
@@ -2,11 +2,17 @@
resource "aws_autoscaling_group" "workers_launch_template_mixed" {
count = local.worker_group_launch_template_mixed_count
name_prefix = "${aws_eks_cluster.this.name}-${lookup(
var.worker_groups_launch_template_mixed[count.index],
"name",
count.index,
)}"
name_prefix = join(
"-",
compact(
[
aws_eks_cluster.this.name,
lookup(var.worker_groups_launch_template_mixed[count.index], "name", count.index),
lookup(var.worker_groups_launch_template_mixed[count.index], "asg_recreate_on_change", local.workers_group_defaults["asg_recreate_on_change"]) ? random_pet.workers_launch_template_mixed[count.index].id : ""
]
)
)
desired_capacity = lookup(
var.worker_groups_launch_template_mixed[count.index],
"asg_desired_capacity",
@@ -338,6 +344,25 @@ resource "aws_launch_template" "workers_launch_template_mixed" {
}
}
resource "random_pet" "workers_launch_template_mixed" {
count = local.worker_group_launch_template_mixed_count
separator = "-"
length = 2
keepers = {
lt_name = join(
"-",
compact(
[
aws_launch_template.workers_launch_template_mixed[count.index].name,
aws_launch_template.workers_launch_template_mixed[count.index].latest_version
]
)
)
}
}
resource "aws_iam_instance_profile" "workers_launch_template_mixed" {
count = var.manage_worker_iam_resources ? local.worker_group_launch_template_mixed_count : 0
name_prefix = aws_eks_cluster.this.name