Defined in: src/cloudwatch-dashboard/cloudwatch-dashboard.ts:100
A CloudWatch dashboard construct with sensible defaults and built-in description widget.
This construct extends the CloudWatch Dashboard directly and provides:
- A prominent text widget displaying the dashboard description at the top
- Optional initial widgets that can be specified during construction
- Direct access to all CloudWatch Dashboard methods and properties
- Automatic removal policy application for easy teardown in ephemeral environments
The construct follows AWS best practices for dashboard design by including descriptive documentation directly in the dashboard interface.
Example
// Basic usage with description only
const dashboard = new CloudWatchDashboard(this, 'AppDashboard', {
dashboardName: 'application-monitoring',
dashboardDescription: 'Monitors API performance and error rates'
});
// Add widgets after creation - direct dashboard access
dashboard.addWidgets(
new cloudwatch.GraphWidget({
title: 'API Requests',
left: [apiRequestMetric],
})
);
// Advanced usage with initial widgets and custom removal policy
const advancedDashboard = new CloudWatchDashboard(this, 'DetailedDashboard', {
dashboardName: 'detailed-monitoring',
dashboardDescription: 'Comprehensive monitoring for production workloads',
periodOverride: cloudwatch.PeriodOverride.AUTO,
removalPolicy: RemovalPolicy.RETAIN, // Keep dashboard when stack is deleted
initialWidgets: [
new cloudwatch.GraphWidget({
title: 'Error Rate',
left: [errorRateMetric],
width: 12,
height: 6,
}),
new cloudwatch.SingleValueWidget({
title: 'Total Requests',
metrics: [totalRequestsMetric],
width: 12,
height: 6,
}),
],
});
Extends
Dashboard
Constructors
Constructor
new CloudWatchDashboard(
scope
,id
,props
):CloudWatchDashboard
Defined in: src/cloudwatch-dashboard/cloudwatch-dashboard.ts:108
Create a new CloudWatch dashboard with description widget and optional initial widgets.
Parameters
scope
Construct
The construct scope.
id
string
Logical ID for this construct.
props
CloudWatchDashboardProps controlling dashboard name, description, and optional initial widgets.
Returns
CloudWatchDashboard
Overrides
cloudwatch.Dashboard.constructor
Properties
dashboardArn
readonly
dashboardArn:string
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:102
ARN of this dashboard
Attribute
Inherited from
cloudwatch.Dashboard.dashboardArn
dashboardName
readonly
dashboardName:string
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:96
The name of this dashboard
Attribute
Inherited from
cloudwatch.Dashboard.dashboardName
env
readonly
env:ResourceEnvironment
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/core/lib/resource.d.ts:111
The environment this resource belongs to. For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
Inherited from
cloudwatch.Dashboard.env
node
readonly
node:Node
Defined in: node_modules/.pnpm/constructs@10.4.2/node_modules/constructs/lib/construct.d.ts:266
The tree node.
Inherited from
cloudwatch.Dashboard.node
stack
readonly
stack:Stack
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/core/lib/resource.d.ts:110
The stack in which this resource is defined.
Inherited from
cloudwatch.Dashboard.stack
PROPERTY_INJECTION_ID
readonly
static
PROPERTY_INJECTION_ID:string
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:90
Uniquely identifies this class.
Inherited from
cloudwatch.Dashboard.PROPERTY_INJECTION_ID
Methods
addVariable()
addVariable(
variable
):void
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:121
Add a variable to the dashboard.
Parameters
variable
IVariable
Returns
void
See
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_dashboard_variables.html
Inherited from
cloudwatch.Dashboard.addVariable
addWidgets()
addWidgets(...
widgets
):void
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/aws-cloudwatch/lib/dashboard.d.ts:115
Add a widget to the dashboard.
Widgets given in multiple calls to add() will be laid out stacked on top of each other.
Multiple widgets added in the same call to add() will be laid out next to each other.
Parameters
widgets
...IWidget
[]
Returns
void
Inherited from
cloudwatch.Dashboard.addWidgets
applyRemovalPolicy()
applyRemovalPolicy(
policy
):void
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/core/lib/resource.d.ts:147
Apply the given removal policy to this resource
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
Parameters
policy
RemovalPolicy
Returns
void
Inherited from
cloudwatch.Dashboard.applyRemovalPolicy
toString()
toString():
string
Defined in: node_modules/.pnpm/constructs@10.4.2/node_modules/constructs/lib/construct.d.ts:279
Returns a string representation of this construct.
Returns
string
Inherited from
cloudwatch.Dashboard.toString
isConstruct()
static
isConstruct(x
):x is Construct
Defined in: node_modules/.pnpm/constructs@10.4.2/node_modules/constructs/lib/construct.d.ts:262
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
Parameters
x
any
Any object
Returns
x is Construct
true if x
is an object created from a class which extends Construct
.
Inherited from
cloudwatch.Dashboard.isConstruct
isOwnedResource()
static
isOwnedResource(construct
):boolean
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/core/lib/resource.d.ts:109
Returns true if the construct was created by CDK, and false otherwise
Parameters
construct
IConstruct
Returns
boolean
Inherited from
cloudwatch.Dashboard.isOwnedResource
isResource()
static
isResource(construct
):construct is Resource
Defined in: node_modules/.pnpm/aws-cdk-lib@2.214.0_constructs@10.4.2/node_modules/aws-cdk-lib/core/lib/resource.d.ts:105
Check whether the given construct is a Resource
Parameters
construct
IConstruct
Returns
construct is Resource
Inherited from
cloudwatch.Dashboard.isResource