Skip to content

Commit

Permalink
Add missing fromAlarmName for Alarm
Browse files Browse the repository at this point in the history
  • Loading branch information
nakedible-p authored Apr 8, 2023
1 parent 4744f50 commit 50d688f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/aws-cdk-lib/aws-cloudwatch/lib/alarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ export enum TreatMissingData {
*/
export class Alarm extends AlarmBase {

/**
* Import an existing CloudWatch alarm provided an Name.
*
* @param scope The parent creating construct (usually `this`)
* @param id The construct's name
* @param alarmName Alarm Name
*/
public static fromAlarmName(scope: Construct, id: string, alarmName: string): IAlarm {
const stack = Stack.of(scope);

return this.fromAlarmArn(scope, id, stack.formatArn({
service: 'cloudwatch',
resource: 'alarm',
resourceName: alarmName,
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
}));
}

/**
* Import an existing CloudWatch alarm provided an ARN
*
Expand Down

0 comments on commit 50d688f

Please sign in to comment.