使用Terraform/Terragrunt自动旋转AMIS



这看起来似乎很愚蠢,但是我一直在寻找有关如何自动化亚马逊AMI以按时间表自动化/提高的说明/教程。这是因为我们有非生产服务器用于开发的服务器,而不需要运行24/7。有人有机会协助或指向我朝着正确的方向指向吗?

这就是我的方式;

resource "aws_autoscaling_schedule" "asg_morning" {
  count                  = "${var.schedule_enabled}"
  scheduled_action_name  = "${upper(var.environment)}-${app}-AM-Schedule"
  min_size               = 1
  max_size               = 1
  desired_capacity       = 1
  recurrence             = "${var.schedule_am}"
  autoscaling_group_name = "${aws_autoscaling_group.app.name}"
}
resource "aws_autoscaling_schedule" "asg_evening" {
  count                  = "${var.schedule_enabled}"
  scheduled_action_name  = "${upper(var.environment)}-${var.app}-PM-Schedule"
  min_size               = 0
  max_size               = 0
  desired_capacity       = 0
  recurrence             = "${var.schedule_pm}"
  autoscaling_group_name = "${aws_autoscaling_group.app.name}"
}

最新更新