通过terraform管理ASG

通过terraform管理ASG,terraform,terraform-provider-aws,aws-auto-scaling,Terraform,Terraform Provider Aws,Aws Auto Scaling,我有一个通过terraform管理的自动缩放策略 代码如下: resource "aws_autoscaling_policy" "agents-scale-up" { name = "agents-scale-up" scaling_adjustment = 1 adjustment_type = "ChangeInCapacity" cooldown = 300 autos

我有一个通过terraform管理的自动缩放策略

代码如下:

resource "aws_autoscaling_policy" "agents-scale-up" {
    name = "agents-scale-up"
    scaling_adjustment = 1
    adjustment_type = "ChangeInCapacity"
    cooldown = 300
    autoscaling_group_name = "${aws_autoscaling_group.agents.name}"
}
我有一个cloudwatch度量警报,它根据阈值调用这个ASP

resource "aws_cloudwatch_metric_alarm" "memory-high" {
    alarm_name = "mem-util-high-agents"
    comparison_operator = "GreaterThanOrEqualToThreshold"
    evaluation_periods = "2"
    metric_name = "MemoryUtilization"
    namespace = "System/Linux"
    period = "300"
    statistic = "Average"
    threshold = "80"
    alarm_description = "This metric monitors ec2 memory for high utilization on agent hosts"
    alarm_actions = [
        "${aws_autoscaling_policy.agents-scale-up.arn}"
    ]
    dimensions = {
        AutoScalingGroupName = "${aws_autoscaling_group.agents.name}"
    }
}
现在,我还想打电话给我的ASP,也就是说,我想在周六晚上缩小规模,周一早上再扩大规模。所以我如何调用ASP,我只知道如何根据我在上面代码中使用的阈值调用ASP


我如何才能对我的两个ASP进行基于时间的调用。

我们做了类似的事情,在办公时间以外扩展,但使用计划的扩展来更改asg的最小值、最大值和所需实例值,而不是云监视警报

对于基于时间的常规缩放,这是更明智的方法



您不应该为了提供更多详细信息而在此网站上创建新问题,而应该编辑现有问题。这是否回答了您的问题?
resource "aws_cloudwatch_metric_alarm" "memory-high" {
    alarm_name = "mem-util-high-agents"
    comparison_operator = "GreaterThanOrEqualToThreshold"
    evaluation_periods = "2"
    metric_name = "MemoryUtilization"
    namespace = "System/Linux"
    period = "300"
    statistic = "Average"
    threshold = "80"
    alarm_description = "This metric monitors ec2 memory for high utilization on agent hosts"
    alarm_actions = [
        "${aws_autoscaling_policy.agents-scale-up.arn}"
    ]
    dimensions = {
        AutoScalingGroupName = "${aws_autoscaling_group.agents.name}"
    }
}