Terraform aws_cloudwatch_metric_alarm与服务器联系时发生错误

时间:2018-09-01 16:04:29

标签: terraform amazon-cloudwatch

我正在使用Terraform创建CloudWatch警报,例如:

resource "aws_cloudwatch_metric_alarm" "terraform_cloudwatch_metric_alarm_CPUUtilization" {
alarm_name = "terraform_cloudwatch_metric_alarm_CPUUtilization"
alarm_description = "terraform_cloudwatch_metric_alarm_CPUUtilization"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = "300"
statistic = "Average"
threshold = "90"
dimensions = {
    "Instance­Id" = "${aws_instance.terraform_instance.id}"
}

}

但是我得到与服务器联系时发生错误enter image description here

当我从控制台创建相同文件时,它工作正常: enter image description here

任何想法为何以及如何解决?

PS 临时解决方法是将local-exec添加到aws_instance provisioner "local-exec" { command = <<-EOF aws cloudwatch put-metric-alarm \ --alarm-name "cloudwatch_metric_alarm_CPUUtilization" \ --alarm-description "cloudwatch_metric_alarm_CPUUtilization" \ --no-actions-enabled \ --metric-name "CPUUtilization" \ --namespace "AWS/EC2" \ --statistic "Average" \ --dimensions "Name=InstanceId,Value=${aws_instance.terraform_instance.id}" \ --period "300" \ --unit "Percent" \ --evaluation-periods "1" \ --threshold "90" \ --comparison-operator "GreaterThanOrEqualToThreshold" \ --treat-missing-data "missing" EOF }

1 个答案:

答案 0 :(得分:2)

问题出在尺寸名称中的SOFT HYPHEN中,VSCode和Sublime 3均正常显示代码: VSCode

Sublime

只有Vim / nano可以正确显示: nano