使用Terraform创建云观察警报但遇到错误 解析错误在1:20:预期“}”,但发现无效序列“$”, 如何在维度和范围内传递多个变量? alarm_actions
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}"]
}
答案 0 :(得分:1)
你不会。相反,你会传入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}"]
}