Skip to content

Commit

Permalink
fix(cloudwatch): AlarmWidget takes IAlarm (#3219)
Browse files Browse the repository at this point in the history
This allows using an imported alarm.

Fixes #3068.
  • Loading branch information
rix0rrr authored and Elad Ben-Israel committed Jul 7, 2019
1 parent cc2275c commit 9948bfd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-cloudwatch/lib/graph.ts
@@ -1,5 +1,5 @@
import cdk = require('@aws-cdk/core');
import { Alarm } from "./alarm";
import { IAlarm } from "./alarm";
import { IMetric } from "./metric-types";
import { ConcreteWidget } from "./widget";

Expand Down Expand Up @@ -74,7 +74,7 @@ export interface AlarmWidgetProps extends MetricWidgetProps {
/**
* The alarm to show
*/
readonly alarm: Alarm;
readonly alarm: IAlarm;

/**
* Left Y axis
Expand Down
18 changes: 17 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts
@@ -1,6 +1,6 @@
import { Stack } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib';
import { Alarm, AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib';

export = {
'add metrics to graphs on either axis'(test: Test) {
Expand Down Expand Up @@ -250,4 +250,20 @@ export = {

test.done();
},

'can use imported alarm with graph'(test: Test) {
// GIVEN
const stack = new Stack();
const alarm = Alarm.fromAlarmArn(stack, 'Alarm', 'arn:aws:cloudwatch:region:account-id:alarm:alarm-name');

// WHEN
new AlarmWidget({
title: 'My fancy graph',
alarm
});

// THEN: Compiles

test.done();
},
};

0 comments on commit 9948bfd

Please sign in to comment.