使用Terraform / Terragrunt

时间:2019-02-27 15:33:33

标签: terraform

这似乎很愚蠢,但是我一直在寻找有关如何自动执行Amazon AMI以便按计划拆卸/启动的说明/教程。这是因为我们有用于开发的非生产服务器,不需要运行24/7。有人可以协助或指出我正确的方向吗?

1 个答案:

答案 0 :(得分:1)

这是我的方法;

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}"
}