我正在尝试使用 terraform 创建复合 cloudwatch 警报。但不幸的是,我的 terraform 代码因以下错误而中断:
错误:创建 CloudWatch 复合警报时出错 (node-count-office-time-composite-alarm-DP-1474-desert):ValidationError:AlarmRule 不得包含前导或尾随空格或为空状态代码:400,请求 ID:272b14ae- e6bd-4e65-8bb8-25372d9a5f7c
以下是我的地形代码:
resource "aws_cloudwatch_composite_alarm" "node_count_office_time_alarm" {
depends_on = [aws_cloudwatch_metric_alarm.node_count, aws_cloudwatch_metric_alarm.office_time]
alarm_description = "Composite alarm for node count & office time"
alarm_name = "node-count-office-time-composite-alarm-${local.postfix}"
alarm_actions = [var.sns_topic_arn]
ok_actions = [var.sns_topic_arn]
alarm_rule =<<-EOF
ALARM(${aws_cloudwatch_metric_alarm.node_count.alarm_name}) AND
ALARM(${aws_cloudwatch_metric_alarm.office_time.alarm_name})
EOF
}
我检查了很多次,我的 alarm_rule 中没有前导或尾随空格。AND 运算符后只有新行。我正在使用 terraform 0.15.3 版本。任何人都面临类似的问题,我该如何解决这个问题?谢谢