Skip to content

Commit b9f4923

Browse files
authored
feat(cloudwatch-actions): support alarm lambda action (#28484)
feat(cloudwatch-action): support alarm lambda action Closes #28483 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 10d5a9f commit b9f4923

13 files changed

+1266
-0
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch-actions/test/integ.lambda-alarm-action.js.snapshot/LambdaAlarmActionIntegrationTestDefaultTestDeployAssertF9F882E5.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch-actions/test/integ.lambda-alarm-action.js.snapshot/LambdaAlarmActionIntegrationTestDefaultTestDeployAssertF9F882E5.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch-actions/test/integ.lambda-alarm-action.js.snapshot/LambdaAlarmActionIntegrationTestStack.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
{
2+
"Resources": {
3+
"inAlarmLambdaServiceRole970DE64C": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"inAlarmLambda0920D101": {
35+
"Type": "AWS::Lambda::Function",
36+
"Properties": {
37+
"Code": {
38+
"ZipFile": "exports.handler = function handler(event, _context, callback) {\n console.log(JSON.stringify(event, undefined, 2));\n return callback();\n}"
39+
},
40+
"FunctionName": "inAlarmLambda",
41+
"Handler": "index.handler",
42+
"Role": {
43+
"Fn::GetAtt": [
44+
"inAlarmLambdaServiceRole970DE64C",
45+
"Arn"
46+
]
47+
},
48+
"Runtime": "nodejs18.x"
49+
},
50+
"DependsOn": [
51+
"inAlarmLambdaServiceRole970DE64C"
52+
]
53+
},
54+
"Alarm7103F465": {
55+
"Type": "AWS::CloudWatch::Alarm",
56+
"Properties": {
57+
"ActionsEnabled": true,
58+
"AlarmActions": [
59+
{
60+
"Ref": "alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b"
61+
},
62+
{
63+
"Ref": "alarmLambdaAliasaliasName41B27313"
64+
},
65+
{
66+
"Fn::GetAtt": [
67+
"alarmLambda131DB691",
68+
"Arn"
69+
]
70+
}
71+
],
72+
"ComparisonOperator": "GreaterThanThreshold",
73+
"Dimensions": [
74+
{
75+
"Name": "FunctionName",
76+
"Value": {
77+
"Ref": "inAlarmLambda0920D101"
78+
}
79+
}
80+
],
81+
"EvaluationPeriods": 1,
82+
"MetricName": "Errors",
83+
"Namespace": "AWS/Lambda",
84+
"Period": 60,
85+
"Statistic": "Sum",
86+
"Threshold": 1,
87+
"TreatMissingData": "notBreaching"
88+
}
89+
},
90+
"alarmLambdaServiceRoleCDAABB9D": {
91+
"Type": "AWS::IAM::Role",
92+
"Properties": {
93+
"AssumeRolePolicyDocument": {
94+
"Statement": [
95+
{
96+
"Action": "sts:AssumeRole",
97+
"Effect": "Allow",
98+
"Principal": {
99+
"Service": "lambda.amazonaws.com"
100+
}
101+
}
102+
],
103+
"Version": "2012-10-17"
104+
},
105+
"ManagedPolicyArns": [
106+
{
107+
"Fn::Join": [
108+
"",
109+
[
110+
"arn:",
111+
{
112+
"Ref": "AWS::Partition"
113+
},
114+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
115+
]
116+
]
117+
}
118+
]
119+
}
120+
},
121+
"alarmLambda131DB691": {
122+
"Type": "AWS::Lambda::Function",
123+
"Properties": {
124+
"Code": {
125+
"ZipFile": "exports.handler = function handler(event, _context, callback) {\n console.log(JSON.stringify(event, undefined, 2));\n return callback();\n}"
126+
},
127+
"FunctionName": "alarmLambda",
128+
"Handler": "index.handler",
129+
"Role": {
130+
"Fn::GetAtt": [
131+
"alarmLambdaServiceRoleCDAABB9D",
132+
"Arn"
133+
]
134+
},
135+
"Runtime": "nodejs18.x"
136+
},
137+
"DependsOn": [
138+
"alarmLambdaServiceRoleCDAABB9D"
139+
]
140+
},
141+
"alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b": {
142+
"Type": "AWS::Lambda::Version",
143+
"Properties": {
144+
"FunctionName": {
145+
"Ref": "alarmLambda131DB691"
146+
}
147+
}
148+
},
149+
"alarmLambdaCurrentVersionAlarmPermissionFEBD056F": {
150+
"Type": "AWS::Lambda::Permission",
151+
"Properties": {
152+
"Action": "lambda:InvokeFunction",
153+
"FunctionName": {
154+
"Ref": "alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b"
155+
},
156+
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
157+
"SourceAccount": {
158+
"Ref": "AWS::AccountId"
159+
},
160+
"SourceArn": {
161+
"Fn::GetAtt": [
162+
"Alarm7103F465",
163+
"Arn"
164+
]
165+
}
166+
}
167+
},
168+
"alarmLambdaAliasaliasName41B27313": {
169+
"Type": "AWS::Lambda::Alias",
170+
"Properties": {
171+
"FunctionName": {
172+
"Ref": "alarmLambda131DB691"
173+
},
174+
"FunctionVersion": {
175+
"Fn::GetAtt": [
176+
"alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b",
177+
"Version"
178+
]
179+
},
180+
"Name": "aliasName"
181+
}
182+
},
183+
"alarmLambdaAliasaliasNameAlarmPermission64A91652": {
184+
"Type": "AWS::Lambda::Permission",
185+
"Properties": {
186+
"Action": "lambda:InvokeFunction",
187+
"FunctionName": {
188+
"Ref": "alarmLambdaAliasaliasName41B27313"
189+
},
190+
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
191+
"SourceAccount": {
192+
"Ref": "AWS::AccountId"
193+
},
194+
"SourceArn": {
195+
"Fn::GetAtt": [
196+
"Alarm7103F465",
197+
"Arn"
198+
]
199+
}
200+
}
201+
},
202+
"alarmLambdaAlarmPermission43E41C89": {
203+
"Type": "AWS::Lambda::Permission",
204+
"Properties": {
205+
"Action": "lambda:InvokeFunction",
206+
"FunctionName": {
207+
"Fn::GetAtt": [
208+
"alarmLambda131DB691",
209+
"Arn"
210+
]
211+
},
212+
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
213+
"SourceAccount": {
214+
"Ref": "AWS::AccountId"
215+
},
216+
"SourceArn": {
217+
"Fn::GetAtt": [
218+
"Alarm7103F465",
219+
"Arn"
220+
]
221+
}
222+
}
223+
}
224+
},
225+
"Parameters": {
226+
"BootstrapVersion": {
227+
"Type": "AWS::SSM::Parameter::Value<String>",
228+
"Default": "/cdk-bootstrap/hnb659fds/version",
229+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
230+
}
231+
},
232+
"Rules": {
233+
"CheckBootstrapVersion": {
234+
"Assertions": [
235+
{
236+
"Assert": {
237+
"Fn::Not": [
238+
{
239+
"Fn::Contains": [
240+
[
241+
"1",
242+
"2",
243+
"3",
244+
"4",
245+
"5"
246+
],
247+
{
248+
"Ref": "BootstrapVersion"
249+
}
250+
]
251+
}
252+
]
253+
},
254+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
255+
}
256+
]
257+
}
258+
}
259+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch-actions/test/integ.lambda-alarm-action.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch-actions/test/integ.lambda-alarm-action.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)