我正在探索使用目标跟踪和自定义指标的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"
}
}
问候。
更新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.
答案 0 :(得分:0)
我遇到了同样的问题,并能够通过向扩展策略资源添加 policy_type
属性来修复它
policy_type = "TargetTrackingScaling"
policy_type - (Optional) The policy type, either "SimpleScaling", "StepScaling", "TargetTrackingScaling", or "PredictiveScaling". If this value isn't provided, AWS will default to "SimpleScaling."