Skip to content

Commit 9948bfd

Browse files
rix0rrrElad Ben-Israel
authored and
Elad Ben-Israel
committed
fix(cloudwatch): AlarmWidget takes IAlarm (#3219)
This allows using an imported alarm. Fixes #3068.
1 parent cc2275c commit 9948bfd

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/@aws-cdk/aws-cloudwatch/lib/graph.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cdk = require('@aws-cdk/core');
2-
import { Alarm } from "./alarm";
2+
import { IAlarm } from "./alarm";
33
import { IMetric } from "./metric-types";
44
import { ConcreteWidget } from "./widget";
55

@@ -74,7 +74,7 @@ export interface AlarmWidgetProps extends MetricWidgetProps {
7474
/**
7575
* The alarm to show
7676
*/
77-
readonly alarm: Alarm;
77+
readonly alarm: IAlarm;
7878

7979
/**
8080
* Left Y axis

packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Stack } from '@aws-cdk/core';
22
import { Test } from 'nodeunit';
3-
import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib';
3+
import { Alarm, AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib';
44

55
export = {
66
'add metrics to graphs on either axis'(test: Test) {
@@ -250,4 +250,20 @@ export = {
250250

251251
test.done();
252252
},
253+
254+
'can use imported alarm with graph'(test: Test) {
255+
// GIVEN
256+
const stack = new Stack();
257+
const alarm = Alarm.fromAlarmArn(stack, 'Alarm', 'arn:aws:cloudwatch:region:account-id:alarm:alarm-name');
258+
259+
// WHEN
260+
new AlarmWidget({
261+
title: 'My fancy graph',
262+
alarm
263+
});
264+
265+
// THEN: Compiles
266+
267+
test.done();
268+
},
253269
};

0 commit comments

Comments
 (0)