我们如何在插值的CloudWatch仪表板中提及实例ID(使用Terraform)

时间:2019-06-20 18:21:25

标签: json amazon-cloudformation terraform terraform-provider-aws

我正在创建一个EC2实例,同时在创建Terrawatch的Cloudwatch仪表板以提高CPU利用率。

我在

中使用了插值:$ {aws_instance.ec2-terminal-server.id}

“指标”:[                 [                    “ AWS / EC2”,                    “ CPUUtilization”,                    “ Instanceid”,                    “ $ {aws_instance.ec2-terminal-server.id}”                 ]

resource "aws_cloudwatch_dashboard" "CWDashboardNotification" {
  dashboard_name = "CPUUtilisation_${var.ec2_tags_name}"

  dashboard_body = <<EOF
 {
   "widgets": [
       {
          "type":"metric",
          "x":0,
          "y":0,
          "width":12,
          "height":6,
          "properties":{
             "metrics":[
                [
                   "AWS/EC2",
                   "CPUUtilization",
                   "Instanceid",
                   "${aws_instance.ec2-terminal-server.id}"
                ]
             ],
             "period":300,
             "stat":"Average",
             "region":"ap-south-1",
             "title":"EC2 Instance CPU"
          }
       }
   ]
 }
 EOF
}```

Output should show the cpu utilisation graph in the dashboard but it's showing blank

0 个答案:

没有答案