【发布时间】:2021-05-25 23:37:57
【问题描述】:
这是cloudwatch_metric_alarm resource 的示例:
resource "aws_cloudwatch_metric_alarm" "nlb_healthyhosts" {
alarm_name = "alarmname"
comparison_operator = "LessThanThreshold"
evaluation_periods = "1"
metric_name = "HealthyHostCount"
namespace = "AWS/NetworkELB"
period = "60"
statistic = "Average"
threshold = var.logstash_servers_count
alarm_description = "Number of healthy nodes in Target Group"
actions_enabled = "true"
alarm_actions = [aws_sns_topic.sns.arn]
ok_actions = [aws_sns_topic.sns.arn]
dimensions = {
TargetGroup = aws_lb_target_group.lb-tg.arn_suffix
LoadBalancer = aws_lb.lb.arn_suffix
}
}
我仍然不明白警报操作参数。在 terraform 文档中,我们有:
alarm_actions - (可选)当此警报从任何其他状态转换为 ALARM 状态时要执行的操作列表。每个 action 被指定为 Amazon 资源名称 (ARN)。
谁能给我一个具体的例子,例如发送电子邮件/和/创建一个 SNS 主题(没有退出主题 ARN)。
非常感谢您的帮助。
【问题讨论】:
-
aws_cloudwatch_metric_alarm资源不处理实际的消息传递,无论是通过电子邮件、SMS 还是其他方式。它唯一要做的就是将消息传递给在alarm_actions中定义的 SNS 主题。
标签: amazon-web-services terraform amazon-cloudwatch