AWS CloudWatch Dashboard
This page shows how to write Terraform and CloudFormation for CloudWatch Dashboard and write them securely.
aws_cloudwatch_dashboard (Terraform)
The Dashboard in CloudWatch can be configured in Terraform with the resource name aws_cloudwatch_dashboard
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_cloudwatch_dashboard" "iaps" {
count = var.deploy_iaps_v1 == false ? 0 : 1
dashboard_name = "iaps"
dashboard_body = data.template_file.iaps_dashboard.rendered
}
resource "aws_cloudwatch_dashboard" "dash" {
dashboard_name = "Brutalismbot"
dashboard_body = file("dashboard.json")
}
resource "aws_cloudwatch_dashboard" "ec2" {
dashboard_name = "ec2-general"
dashboard_body = jsonencode({
"widgets" : [
{
"type" : "explorer",
resource "aws_cloudwatch_dashboard" "this" {
dashboard_body = var.dashboard_body
dashboard_name = var.dashboard_name
}
resource "aws_cloudwatch_dashboard" "www-bds-code" {
dashboard_name = "www-bds-code"
dashboard_body = <<EOF
{
"widgets": [
Parameters
-
dashboard_arn
optional computed - string -
dashboard_body
required - string -
dashboard_name
required - string -
id
optional computed - string
Explanation in Terraform Registry
Provides a CloudWatch Dashboard resource.
AWS::CloudWatch::Dashboard (CloudFormation)
The Dashboard in CloudWatch can be configured in CloudFormation with the resource name AWS::CloudWatch::Dashboard
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
DashboardName
optional - String -
DashboardBody
required - String
Explanation in CloudFormation Registry
The
AWS::CloudWatch::Dashboard
resource specifies an Amazon CloudWatch dashboard. A dashboard is a customizable home page in the CloudWatch console that you can use to monitor your AWS resources in a single view.All dashboards in your account are global, not region-specific.
Frequently asked questions
What is AWS CloudWatch Dashboard?
AWS CloudWatch Dashboard is a resource for CloudWatch of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS CloudWatch Dashboard?
For Terraform, the ministryofjustice/hmpps-delius-iaps-shared-terraform, brutalismbot/monitoring and BradleyChatha/infrastructure source code examples are useful. See the Terraform Example section for further details.