我正在探索具有目标跟踪和自定义指标的AWS EC2自动扩展 . 从我理解的文档中,当命中特定目标时,会触发自动缩放事件,该事件可以扩展到EC2实例或从中扩展出来 .

我按照aws_autoscaling_policy的terraform文档提供的说明进行操作,但是这只是缩放进出一个实例 .

现在,对于我的用例,我想扩展和扩展两个实例 . 有没有办法通过目标跟踪扩展策略来实现这一目标?

任何帮助,非常感谢 .

以下是使用terraform编写的工作策略,用于使用自定义指标进行目标跟踪 .

resource "aws_autoscaling_policy" "target-tracking-autoscale" {

name = "target-traclking-policy"

autoscaling_group_name = "target-tracking-asg"
policy_type            = "TargetTrackingScaling"

target_tracking_configuration {
    customized_metric_specification {
        metric_dimension {
            name  = "asg"
            value = "custom-value"
        }

        metric_name = "CUSTOM_METRIC"
        namespace   = "CUSTOM-METRIC/NAMESPACE"
        statistic   = "Average"
        }
        target_value = "2"
    }
}

问候 .


Update 1

我尝试添加 step_adjustment 但此参数仅用于步进缩放 . Terraform抛出以下错误:

Error: Error applying plan:

1 error(s) occurred:

* module.pt-wowza.aws_autoscaling_policy.target-tracking-autoscale: 1 error(s) occurred:

* aws_autoscaling_policy.target-tracking-autoscale: step_adjustment is only supported for policy type StepScaling

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.