Skip to content

Commit

Permalink
feat(aws-cloudwatch-actions): add ssm incidents as alarm action
Browse files Browse the repository at this point in the history
Finishes work originally contributed by @dosatos by addressing changes requested by @comcalvi in aws#20553
closes aws#20552
  • Loading branch information
callumthomson committed Jul 15, 2022
1 parent a85da25 commit e002868
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudwatch-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ declare const alarm: cloudwatch.Alarm;
// Create an Incident Manager incident based on a specific response plan
alarm.addAlarmAction(
new actions.SsmIncidentAction(
'arn:aws:ssm-incidents::123456789012:response-plan/ResponsePlanName'
'arn:aws:ssm-incidents::123456789012:response-plan/ResponsePlanName',
)
);
```
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch-actions/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from './autoscaling';
export * from './sns';
export * from './ec2';
export * from './ssm';
export * from './ssm-incidents';
20 changes: 0 additions & 20 deletions packages/@aws-cdk/aws-cloudwatch-actions/lib/ssm-incidents.ts

This file was deleted.

17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch-actions/lib/ssm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,20 @@ export class SsmAction implements cloudwatch.IAlarmAction {
}
}

/**
* Use an SSM Incident Response Plan as an Alarm action
*/
export class SsmIncidentAction implements cloudwatch.IAlarmAction {
constructor(private readonly responsePlanArn: string) {}

/**
* Returns an alarm action configuration to use an SSM Incident as an alarm action
* based on an Incident Manager Response Plan
*/
bind(_scope: Construct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig {
return {
alarmActionArn: this.responsePlanArn,
};
}
}

0 comments on commit e002868

Please sign in to comment.