feat: Add Autoscaling schedule for EKS managed node group (#2504)

Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
This commit is contained in:
Le Minh Duc
2023-03-31 21:46:27 +07:00
committed by GitHub
parent 2cf6a5bc14
commit 4a2523cddd
8 changed files with 78 additions and 3 deletions

View File

@@ -447,3 +447,25 @@ resource "aws_iam_role_policy_attachment" "additional" {
policy_arn = each.value
role = aws_iam_role.this[0].name
}
################################################################################
# Autoscaling Group Schedule
################################################################################
resource "aws_autoscaling_schedule" "this" {
for_each = { for k, v in var.schedules : k => v if var.create && var.create_schedule }
scheduled_action_name = each.key
autoscaling_group_name = aws_eks_node_group.this[0].resources[0].autoscaling_groups[0].name
min_size = try(each.value.min_size, null)
max_size = try(each.value.max_size, null)
desired_capacity = try(each.value.desired_size, null)
start_time = try(each.value.start_time, null)
end_time = try(each.value.end_time, null)
time_zone = try(each.value.time_zone, null)
# [Minute] [Hour] [Day_of_Month] [Month_of_Year] [Day_of_Week]
# Cron examples: https://crontab.guru/examples.html
recurrence = try(each.value.recurrence, null)
}