amazon-web-services - 使用 terraform 创建 Cloud watch 警报并在警报命中时发送通知
问题描述
使用 Terraform 创建 cloudwatch 警报,但在 1:20 遇到错误解析错误:预期 "}" 但发现无效序列 "$" ,如何在维度和警报操作中传递多个变量
variable "sfn_name" { }
variable "sns_topic" { }
resource "aws_cloudwatch_metric_alarm" "checkQueueLength" {
alarm_name = "MonitorQueueLength"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "ExecutionsStarted"
namespace = "AWS/States"
period = "2"
statistic = "Sum"
threshold = "1"
dimensions {
StateMachineArn = "${aws_sfn_activity.${var.sfn_name}.arn}"
alarm_description = "checkStatesQueueLength"
actions_enabled = "true"
}
alarm_actions = ["${aws_sns_topic.${var.sns_topic}.arn}"]
}
解决方案
你不会的。相反,您将传入 aws_sfn_activity 和 sns 主题 arn。
variable "sfn_arn" { }
variable "sns_topic_arn" { }
resource "aws_cloudwatch_metric_alarm" "checkQueueLength" {
alarm_name = "MonitorQueueLength"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "ExecutionsStarted"
namespace = "AWS/States"
period = "2"
statistic = "Sum"
threshold = "1"
dimensions {
StateMachineArn = "${var.sfn_arn}"
alarm_description = "checkStatesQueueLength"
actions_enabled = "true"
}
alarm_actions = ["${var.sns_topic_arn}"]
}
推荐阅读
- angular - 如何使用 RxJS 取消 Angular 服务中以前的 HTTP 请求
- python - 安装后无法导入 discord.py
- huawei-mobile-services - 华为推送工具包:SendException:设备不在设备组中
- ionic-framework - 应用程序浏览器中的离子在其他浏览器中打开网址
- python - Tkinter Python - 带有滚动条、画布和按钮的框架(滚动条不起作用)
- sql - 规范化 SQL 表 - 将 1 行转换为 6 行
- python - 如何将类对象添加到列表中?
- react-native - 反应本机设置错误。无法创建Java虚拟机
- node.js - 因未创建 Visual Studio 2017 而获得。原因?
- svg - 如何使用 SVG 作为 PWA 图标?