1

I created terraform file to create dashboard in AWS cloudwatch.

here is my sample file to create dashboard

// provider module

provider "aws"{
    access_key = var.access_key                 
    secret_key = var.secret_key
    region     = var.region
        }

// cloudwatch dashboard module

resource "aws_cloudwatch_dashboard" "main" {
  dashboard_name = var.dashboard_name

  dashboard_body = <<EOF
{
  "widgets": [
    {
      "type": "metric",
      "x": 0,
      "y": 0,
      "width": 12,
      "height": 6,
      "properties": {
        "metrics": [
          [
            "AWS/EBS",
            "VolumeReadOps",
            "VolumeId",
            "vol-04b26d88efe8ecd54"
          ]
        ],
        "period": 300,
        "stat": "Average",
        "region": "ap-south-1",
        "title": "VolumeRead"
      }
    },
    {
      "type": "metric",
      "x": 0,
      "y": 0,
      "width": 12,
      "height": 6,
      "properties": {
        "metrics": [
          [
            "AWS/EBS",
            "VolumeQueueLength",
            "VolumeId",
            "vol-04b26d88efe8ecd54"
          ]
        ],
        "period": 300,
        "stat": "Average",
        "region": "ap-south-1",
        "title": "VolumeQueueLength"
      }
    },
    {
      "type": "metric",
      "x": 14,
      "y": 13,
      "width": 12,
      "height": 6,
      "properties": {
        "metrics": [
          [
            "AWS/EBS",
            "BurstBalance",
            "VolumeId",
            "vol-04b26d88efe8ecd54"
          ]
        ],
        "period": 300,
        "stat": "Average",
        "region": "ap-south-1",
        "title": "BurstBalance"
      }
    }
  ]
}
EOF
}

Is there any possibility to add all the metrics available in the particular resource (eg:ec2, ebs, rds) in same widget or separate widget for each all the metrics in one function without indicating every metrics in separate function in terraform file?

In aws console just tick the checkbox above all the metrics inside the resource will include all the metrics in same widget. But i couldnt find the proper answer for terraform provision

jayaprakash R
  • 152
  • 3
  • 13

0 Answers0