簡體   English   中英

是否可以使用 Terraform 為 AutoScaling 組的同一 CloudWatch 警報創建多個條件?

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

這是我的資源,我需要它遵循 2 個條件:

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 文檔Terraform 文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM