-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws-cloudwatch-actions): Add the possibility to have SSM Incident Action #20553
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -3,3 +3,4 @@ export * from './autoscaling'; | |||||||
export * from './sns'; | ||||||||
export * from './ec2'; | ||||||||
export * from './ssm'; | ||||||||
export * from './ssm-incidents'; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,20 @@ | ||||||||
import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic should be moved into |
||||||||
import { Construct } from '@aws-cdk/core'; | ||||||||
|
||||||||
/** | ||||||||
* Use an SSM Incident as an alarm action | ||||||||
*/ | ||||||||
export class SsmIncidentAction implements cloudwatch.IAlarmAction { | ||||||||
constructor(private readonly responsePlanArn: string) { | ||||||||
} | ||||||||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
/** | ||||||||
* 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, | ||||||||
}; | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Template } from '@aws-cdk/assertions'; | ||
import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; | ||
import { Stack } from '@aws-cdk/core'; | ||
import * as actions from '../lib'; | ||
|
||
test('can use SSM Incident as alarm action', () => { | ||
// GIVEN | ||
const stack = new Stack(); | ||
const alarm = new cloudwatch.Alarm(stack, 'Alarm', { | ||
metric: new cloudwatch.Metric({ namespace: 'AWS', metricName: 'Test' }), | ||
evaluationPeriods: 3, | ||
threshold: 100, | ||
}); | ||
|
||
// WHEN | ||
const responsePlanArn = 'arn:aws:ssm-incidents::123456789012:response-plan/ResponsePlanName'; | ||
alarm.addAlarmAction(new actions.SsmIncidentAction(responsePlanArn)); | ||
|
||
// THEN | ||
Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', { | ||
AlarmActions: [responsePlanArn], | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.