可以为AutoScaling组的同一个CloudWatch告警创建多个条件?



这是我的资源,我需要它遵循两个条件:

ASG最小尺寸>阈值

ASG最小尺寸<阈值>


resource "aws_cloudwatch_metric_alarm" "GroupMinSize" {
count               = 1
alarm_name          = "Autoscaling_Group_Min_Size"
comparison_operator = "GreaterThanThreshold"
evaluation_periods  = "2"
metric_name         = "GroupMinSize"
namespace           = "AWS/AutoScaling"
statistic           = "Minimum"
period              = "120"
threshold           = 1
dimensions = {
AutoScalingGroupName = aws_autoscaling_group.asg[count.index].name
}
alarm_description = "The minimum size of the Auto Scaling group"
}

根据AWS cloudformation文档,comparison_operator是一个字符串,因此不能有多个条件。如果cloudformation做不到,Terraform也做不到。

ComparisonOperator
The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand.
You can specify the following values: GreaterThanThreshold, GreaterThanOrEqualToThreshold, LessThanThreshold, or LessThanOrEqualToThreshold.
Required: Yes
Type: String
Allowed values: GreaterThanOrEqualToThreshold | GreaterThanThreshold | GreaterThanUpperThreshold | LessThanLowerOrGreaterThanUpperThreshold | LessThanLowerThreshold | LessThanOrEqualToThreshold | LessThanThreshold

但是,您可以将多个告警组合成一个复合。

Cloudformation-documentationTerraform-documentation

最新更新