Skip to content

Commit

Permalink
feat(cloudwatch): expose dashboardName property on the L2 Dashboard c…
Browse files Browse the repository at this point in the history
…onstruct (#17721)

Exposes `dashboardName` property on `Dashboard` construct. 

closes issue #17648 
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
pedrosola committed Apr 27, 2022
1 parent 4764591 commit 8cb5dff
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch/lib/dashboard.ts
Expand Up @@ -75,6 +75,14 @@ export interface DashboardProps {
* A CloudWatch dashboard
*/
export class Dashboard extends Resource {

/**
* The name of this dashboard
*
* @attribute
*/
public readonly dashboardName: string;

/**
* ARN of this dashboard
*
Expand All @@ -99,7 +107,7 @@ export class Dashboard extends Resource {
}
}

new CfnDashboard(this, 'Resource', {
const dashboard = new CfnDashboard(this, 'Resource', {
dashboardName: this.physicalName,
dashboardBody: Lazy.string({
produce: () => {
Expand All @@ -115,6 +123,8 @@ export class Dashboard extends Resource {
}),
});

this.dashboardName = this.getResourceNameAttribute(dashboard.ref);

(props.widgets || []).forEach(row => {
this.addWidgets(...row);
});
Expand Down

0 comments on commit 8cb5dff

Please sign in to comment.