Resource: aws_cloudwatch_dashboard

Provides a CloudWatch Dashboard resource.

Example Usage

resource "aws_cloudwatch_dashboard" "main" {
  dashboard_name = "my-dashboard"

  dashboard_body = jsonencode({
    widgets = [
      {
        type   = "metric"
        x      = 0
        y      = 0
        width  = 12
        height = 6

        properties = {
          metrics = [
            [
              "AWS/EC2",
              "CPUUtilization",
              "InstanceId",
              "i-012345"
            ]
          ]
          period = 300
          stat   = "Average"
          region = "us-east-1"
          title  = "EC2 Instance CPU"
        }
      },
      {
        type   = "text"
        x      = 0
        y      = 7
        width  = 3
        height = 3

        properties = {
          markdown = "Hello world"
        }
      }
    ]
  })
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import CloudWatch dashboards using the dashboard_name. For example:

import {
  to = aws_cloudwatch_dashboard.sample
  id = "dashboard_name"
}

Using terraform import, import CloudWatch dashboards using the dashboard_name. For example:

% terraform import aws_cloudwatch_dashboard.sample dashboard_name