简体   繁体   English

是否可以使用 Terraform 为 AutoScaling 组的同一 CloudWatch 警报创建多个条件?

[英]It is possible to create multiple conditions for the same CloudWatch alarm for AutoScaling group with Terraform?

This is my resource and I need it to follow 2 conditions:这是我的资源,我需要它遵循 2 个条件:

ASG min size > threshold ASG 最小尺寸 > 阈值

ASG min size < threshold 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"
}

According to AWS cloudformation documentation, comparison_operator is a string, therefore you cannot have multiple conditions.根据 AWS cloudformation 文档, comparison_operator是一个字符串,因此您不能有多个条件。 If cloudformation cannot do it, Terraform cannot do it either.如果 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

However, you can combine multiple alarms to make a composite.但是,您可以组合多个警报以进行复合。

Cloudformation-documentation Terraform-documentation Cloudformation 文档Terraform 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM