-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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*
- Loading branch information
Showing
13 changed files
with
1,266 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...n.js.snapshot/LambdaAlarmActionIntegrationTestDefaultTestDeployAssertF9F882E5.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...js.snapshot/LambdaAlarmActionIntegrationTestDefaultTestDeployAssertF9F882E5.template.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...t/integ.lambda-alarm-action.js.snapshot/LambdaAlarmActionIntegrationTestStack.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
259 changes: 259 additions & 0 deletions
259
...integ.lambda-alarm-action.js.snapshot/LambdaAlarmActionIntegrationTestStack.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,259 @@ | ||
{ | ||
"Resources": { | ||
"inAlarmLambdaServiceRole970DE64C": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"inAlarmLambda0920D101": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "exports.handler = function handler(event, _context, callback) {\n console.log(JSON.stringify(event, undefined, 2));\n return callback();\n}" | ||
}, | ||
"FunctionName": "inAlarmLambda", | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"inAlarmLambdaServiceRole970DE64C", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"inAlarmLambdaServiceRole970DE64C" | ||
] | ||
}, | ||
"Alarm7103F465": { | ||
"Type": "AWS::CloudWatch::Alarm", | ||
"Properties": { | ||
"ActionsEnabled": true, | ||
"AlarmActions": [ | ||
{ | ||
"Ref": "alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b" | ||
}, | ||
{ | ||
"Ref": "alarmLambdaAliasaliasName41B27313" | ||
}, | ||
{ | ||
"Fn::GetAtt": [ | ||
"alarmLambda131DB691", | ||
"Arn" | ||
] | ||
} | ||
], | ||
"ComparisonOperator": "GreaterThanThreshold", | ||
"Dimensions": [ | ||
{ | ||
"Name": "FunctionName", | ||
"Value": { | ||
"Ref": "inAlarmLambda0920D101" | ||
} | ||
} | ||
], | ||
"EvaluationPeriods": 1, | ||
"MetricName": "Errors", | ||
"Namespace": "AWS/Lambda", | ||
"Period": 60, | ||
"Statistic": "Sum", | ||
"Threshold": 1, | ||
"TreatMissingData": "notBreaching" | ||
} | ||
}, | ||
"alarmLambdaServiceRoleCDAABB9D": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"alarmLambda131DB691": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "exports.handler = function handler(event, _context, callback) {\n console.log(JSON.stringify(event, undefined, 2));\n return callback();\n}" | ||
}, | ||
"FunctionName": "alarmLambda", | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"alarmLambdaServiceRoleCDAABB9D", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"alarmLambdaServiceRoleCDAABB9D" | ||
] | ||
}, | ||
"alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b": { | ||
"Type": "AWS::Lambda::Version", | ||
"Properties": { | ||
"FunctionName": { | ||
"Ref": "alarmLambda131DB691" | ||
} | ||
} | ||
}, | ||
"alarmLambdaCurrentVersionAlarmPermissionFEBD056F": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Ref": "alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b" | ||
}, | ||
"Principal": "lambda.alarms.cloudwatch.amazonaws.com", | ||
"SourceAccount": { | ||
"Ref": "AWS::AccountId" | ||
}, | ||
"SourceArn": { | ||
"Fn::GetAtt": [ | ||
"Alarm7103F465", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"alarmLambdaAliasaliasName41B27313": { | ||
"Type": "AWS::Lambda::Alias", | ||
"Properties": { | ||
"FunctionName": { | ||
"Ref": "alarmLambda131DB691" | ||
}, | ||
"FunctionVersion": { | ||
"Fn::GetAtt": [ | ||
"alarmLambdaCurrentVersionBDCE825C61967a018dfe55c69152d31b6e7ab40b", | ||
"Version" | ||
] | ||
}, | ||
"Name": "aliasName" | ||
} | ||
}, | ||
"alarmLambdaAliasaliasNameAlarmPermission64A91652": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Ref": "alarmLambdaAliasaliasName41B27313" | ||
}, | ||
"Principal": "lambda.alarms.cloudwatch.amazonaws.com", | ||
"SourceAccount": { | ||
"Ref": "AWS::AccountId" | ||
}, | ||
"SourceArn": { | ||
"Fn::GetAtt": [ | ||
"Alarm7103F465", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"alarmLambdaAlarmPermission43E41C89": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Fn::GetAtt": [ | ||
"alarmLambda131DB691", | ||
"Arn" | ||
] | ||
}, | ||
"Principal": "lambda.alarms.cloudwatch.amazonaws.com", | ||
"SourceAccount": { | ||
"Ref": "AWS::AccountId" | ||
}, | ||
"SourceArn": { | ||
"Fn::GetAtt": [ | ||
"Alarm7103F465", | ||
"Arn" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...work-integ/test/aws-cloudwatch-actions/test/integ.lambda-alarm-action.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...k-integ/test/aws-cloudwatch-actions/test/integ.lambda-alarm-action.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.