forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aws-cloudwatch-actions): add ssm incidents as alarm action (aws#…
…21167) Finishes work originally contributed by @dosatos by addressing changes requested by @comcalvi in [aws#20553](aws#20553) closes [aws#20552](aws#20552)
- Loading branch information
1 parent
7acd9e9
commit def0b15
Showing
11 changed files
with
369 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/@aws-cdk/aws-cloudwatch-actions/test/integ.ssm-incident-alarm-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; | ||
import * as ssmIncidents from '@aws-cdk/aws-ssmincidents'; | ||
import { App, Stack, StackProps } from '@aws-cdk/core'; | ||
import * as integ from '@aws-cdk/integ-tests'; | ||
|
||
import * as cloudwatchActions from '../lib'; | ||
|
||
class SsmIncidentAlarmActionIntegrationTestStack extends Stack { | ||
|
||
constructor(scope: App, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const responsePlanName = 'test-response-plan'; | ||
|
||
new ssmIncidents.CfnResponsePlan(this, 'ResponsePlan', { | ||
name: responsePlanName, | ||
incidentTemplate: { | ||
title: 'Incident Title', | ||
impact: 1, | ||
}, | ||
}); | ||
|
||
const metric = new cloudwatch.Metric({ | ||
namespace: 'CDK/Test', | ||
metricName: 'Metric', | ||
label: 'Metric [AVG: ${AVG}]', | ||
}); | ||
|
||
const alarm = new cloudwatch.Alarm(this, 'Alarm1', { | ||
metric, | ||
threshold: 100, | ||
evaluationPeriods: 3, | ||
}); | ||
|
||
alarm.addAlarmAction(new cloudwatchActions.SsmIncidentAction(responsePlanName)); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
|
||
const stack = new SsmIncidentAlarmActionIntegrationTestStack(app, 'SsmIncidentAlarmActionIntegrationTestStack'); | ||
|
||
new integ.IntegTest(app, 'SsmIncidentManagerAlarmActionTest', { | ||
testCases: [stack], | ||
}); | ||
|
||
app.synth(); |
55 changes: 55 additions & 0 deletions
55
...dent-alarm-action.integ.snapshot/SsmIncidentAlarmActionIntegrationTestStack.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"Resources": { | ||
"ResponsePlan": { | ||
"Type": "AWS::SSMIncidents::ResponsePlan", | ||
"Properties": { | ||
"IncidentTemplate": { | ||
"Impact": 1, | ||
"Title": "Incident Title" | ||
}, | ||
"Name": "test-response-plan" | ||
} | ||
}, | ||
"Alarm1F9009D71": { | ||
"Type": "AWS::CloudWatch::Alarm", | ||
"Properties": { | ||
"ComparisonOperator": "GreaterThanOrEqualToThreshold", | ||
"EvaluationPeriods": 3, | ||
"AlarmActions": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":ssm-incidents::", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":response-plan/test-response-plan" | ||
] | ||
] | ||
} | ||
], | ||
"Metrics": [ | ||
{ | ||
"Id": "m1", | ||
"Label": "Metric [AVG: ${AVG}]", | ||
"MetricStat": { | ||
"Metric": { | ||
"MetricName": "Metric", | ||
"Namespace": "CDK/Test" | ||
}, | ||
"Period": 300, | ||
"Stat": "Average" | ||
}, | ||
"ReturnData": true | ||
} | ||
], | ||
"Threshold": 100 | ||
} | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...g.snapshot/SsmIncidentManagerAlarmActionTestDefaultTestDeployAssert9DC05EC0.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
1 change: 1 addition & 0 deletions
1
...ges/@aws-cdk/aws-cloudwatch-actions/test/ssm-incident-alarm-action.integ.snapshot/cdk.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":"20.0.0"} |
11 changes: 11 additions & 0 deletions
11
.../@aws-cdk/aws-cloudwatch-actions/test/ssm-incident-alarm-action.integ.snapshot/integ.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "20.0.0", | ||
"testCases": { | ||
"SsmIncidentManagerAlarmActionTest/DefaultTest": { | ||
"stacks": [ | ||
"SsmIncidentAlarmActionIntegrationTestStack" | ||
], | ||
"assertionStack": "SsmIncidentManagerAlarmActionTestDefaultTestDeployAssert9DC05EC0" | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ws-cdk/aws-cloudwatch-actions/test/ssm-incident-alarm-action.integ.snapshot/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"version": "20.0.0", | ||
"artifacts": { | ||
"Tree": { | ||
"type": "cdk:tree", | ||
"properties": { | ||
"file": "tree.json" | ||
} | ||
}, | ||
"SsmIncidentAlarmActionIntegrationTestStack": { | ||
"type": "aws:cloudformation:stack", | ||
"environment": "aws://unknown-account/unknown-region", | ||
"properties": { | ||
"templateFile": "SsmIncidentAlarmActionIntegrationTestStack.template.json", | ||
"validateOnSynth": false | ||
}, | ||
"metadata": { | ||
"/SsmIncidentAlarmActionIntegrationTestStack/ResponsePlan": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "ResponsePlan" | ||
} | ||
], | ||
"/SsmIncidentAlarmActionIntegrationTestStack/Alarm1/Resource": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Alarm1F9009D71" | ||
} | ||
] | ||
}, | ||
"displayName": "SsmIncidentAlarmActionIntegrationTestStack" | ||
}, | ||
"SsmIncidentManagerAlarmActionTestDefaultTestDeployAssert9DC05EC0": { | ||
"type": "aws:cloudformation:stack", | ||
"environment": "aws://unknown-account/unknown-region", | ||
"properties": { | ||
"templateFile": "SsmIncidentManagerAlarmActionTestDefaultTestDeployAssert9DC05EC0.template.json", | ||
"validateOnSynth": false | ||
}, | ||
"displayName": "SsmIncidentManagerAlarmActionTest/DefaultTest/DeployAssert" | ||
} | ||
} | ||
} |
144 changes: 144 additions & 0 deletions
144
...s/@aws-cdk/aws-cloudwatch-actions/test/ssm-incident-alarm-action.integ.snapshot/tree.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{ | ||
"version": "tree-0.1", | ||
"tree": { | ||
"id": "App", | ||
"path": "", | ||
"children": { | ||
"Tree": { | ||
"id": "Tree", | ||
"path": "Tree", | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/core.Construct", | ||
"version": "0.0.0" | ||
} | ||
}, | ||
"SsmIncidentAlarmActionIntegrationTestStack": { | ||
"id": "SsmIncidentAlarmActionIntegrationTestStack", | ||
"path": "SsmIncidentAlarmActionIntegrationTestStack", | ||
"children": { | ||
"ResponsePlan": { | ||
"id": "ResponsePlan", | ||
"path": "SsmIncidentAlarmActionIntegrationTestStack/ResponsePlan", | ||
"attributes": { | ||
"aws:cdk:cloudformation:type": "AWS::SSMIncidents::ResponsePlan", | ||
"aws:cdk:cloudformation:props": { | ||
"incidentTemplate": { | ||
"title": "Incident Title", | ||
"impact": 1 | ||
}, | ||
"name": "test-response-plan" | ||
} | ||
}, | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/aws-ssmincidents.CfnResponsePlan", | ||
"version": "0.0.0" | ||
} | ||
}, | ||
"Alarm1": { | ||
"id": "Alarm1", | ||
"path": "SsmIncidentAlarmActionIntegrationTestStack/Alarm1", | ||
"children": { | ||
"Resource": { | ||
"id": "Resource", | ||
"path": "SsmIncidentAlarmActionIntegrationTestStack/Alarm1/Resource", | ||
"attributes": { | ||
"aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", | ||
"aws:cdk:cloudformation:props": { | ||
"comparisonOperator": "GreaterThanOrEqualToThreshold", | ||
"evaluationPeriods": 3, | ||
"alarmActions": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":ssm-incidents::", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":response-plan/test-response-plan" | ||
] | ||
] | ||
} | ||
], | ||
"metrics": [ | ||
{ | ||
"metricStat": { | ||
"metric": { | ||
"metricName": "Metric", | ||
"namespace": "CDK/Test" | ||
}, | ||
"period": 300, | ||
"stat": "Average" | ||
}, | ||
"id": "m1", | ||
"label": "Metric [AVG: ${AVG}]", | ||
"returnData": true | ||
} | ||
], | ||
"threshold": 100 | ||
} | ||
}, | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/aws-cloudwatch.CfnAlarm", | ||
"version": "0.0.0" | ||
} | ||
} | ||
}, | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/aws-cloudwatch.Alarm", | ||
"version": "0.0.0" | ||
} | ||
} | ||
}, | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/core.Stack", | ||
"version": "0.0.0" | ||
} | ||
}, | ||
"SsmIncidentManagerAlarmActionTest": { | ||
"id": "SsmIncidentManagerAlarmActionTest", | ||
"path": "SsmIncidentManagerAlarmActionTest", | ||
"children": { | ||
"DefaultTest": { | ||
"id": "DefaultTest", | ||
"path": "SsmIncidentManagerAlarmActionTest/DefaultTest", | ||
"children": { | ||
"Default": { | ||
"id": "Default", | ||
"path": "SsmIncidentManagerAlarmActionTest/DefaultTest/Default", | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/core.Construct", | ||
"version": "0.0.0" | ||
} | ||
}, | ||
"DeployAssert": { | ||
"id": "DeployAssert", | ||
"path": "SsmIncidentManagerAlarmActionTest/DefaultTest/DeployAssert", | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/core.Stack", | ||
"version": "0.0.0" | ||
} | ||
} | ||
}, | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/integ-tests.IntegTestCase", | ||
"version": "0.0.0" | ||
} | ||
} | ||
}, | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/integ-tests.IntegTest", | ||
"version": "0.0.0" | ||
} | ||
} | ||
}, | ||
"constructInfo": { | ||
"fqn": "@aws-cdk/core.App", | ||
"version": "0.0.0" | ||
} | ||
} | ||
} |
Oops, something went wrong.