Skip to content
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

fix(cloudwatch-actions): multiple alarms with LambdaAction for the same Lambda fail (under feature flag) #28712

Merged
merged 10 commits into from
Jan 25, 2024

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,355 @@
{
"Resources": {
"inAlarmLambdaFeatureServiceRoleA2CD21D1": {
"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"
]
]
}
]
}
},
"inAlarmLambdaFeature6C78D351": {
"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": "inAlarmLambdaFeature",
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"inAlarmLambdaFeatureServiceRoleA2CD21D1",
"Arn"
]
},
"Runtime": "nodejs18.x"
},
"DependsOn": [
"inAlarmLambdaFeatureServiceRoleA2CD21D1"
]
},
"Alarm7103F465": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ActionsEnabled": true,
"AlarmActions": [
{
"Ref": "alarmLambdaFeatureCurrentVersionCF39751979501d2f67eaf906b2ef0c378303873b"
},
{
"Ref": "alarmLambdaFeatureAliasaliasName16F91D34"
},
{
"Fn::GetAtt": [
"alarmLambdaFeatureD560800F",
"Arn"
]
}
],
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "FunctionName",
"Value": {
"Ref": "inAlarmLambdaFeature6C78D351"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "Errors",
"Namespace": "AWS/Lambda",
"Period": 60,
"Statistic": "Sum",
"Threshold": 1,
"TreatMissingData": "notBreaching"
}
},
"alarmLambdaFeatureServiceRole853A864D": {
"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"
]
]
}
]
}
},
"alarmLambdaFeatureD560800F": {
"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": "alarmLambdaFeature",
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"alarmLambdaFeatureServiceRole853A864D",
"Arn"
]
},
"Runtime": "nodejs18.x"
},
"DependsOn": [
"alarmLambdaFeatureServiceRole853A864D"
]
},
"alarmLambdaFeatureCurrentVersionCF39751979501d2f67eaf906b2ef0c378303873b": {
"Type": "AWS::Lambda::Version",
"Properties": {
"FunctionName": {
"Ref": "alarmLambdaFeatureD560800F"
}
}
},
"alarmLambdaFeatureCurrentVersionAlarmAlarmPermissionA0D80E66": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Ref": "alarmLambdaFeatureCurrentVersionCF39751979501d2f67eaf906b2ef0c378303873b"
},
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
"SourceAccount": {
"Ref": "AWS::AccountId"
},
"SourceArn": {
"Fn::GetAtt": [
"Alarm7103F465",
"Arn"
]
}
}
},
"alarmLambdaFeatureCurrentVersionAlarmFeatureAlarmPermission192451B4": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Ref": "alarmLambdaFeatureCurrentVersionCF39751979501d2f67eaf906b2ef0c378303873b"
},
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
"SourceAccount": {
"Ref": "AWS::AccountId"
},
"SourceArn": {
"Fn::GetAtt": [
"AlarmFeature9DD74C42",
"Arn"
]
}
}
},
"alarmLambdaFeatureAliasaliasName16F91D34": {
"Type": "AWS::Lambda::Alias",
"Properties": {
"FunctionName": {
"Ref": "alarmLambdaFeatureD560800F"
},
"FunctionVersion": {
"Fn::GetAtt": [
"alarmLambdaFeatureCurrentVersionCF39751979501d2f67eaf906b2ef0c378303873b",
"Version"
]
},
"Name": "aliasName"
}
},
"alarmLambdaFeatureAliasaliasNameAlarmAlarmPermissionE344338D": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Ref": "alarmLambdaFeatureAliasaliasName16F91D34"
},
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
"SourceAccount": {
"Ref": "AWS::AccountId"
},
"SourceArn": {
"Fn::GetAtt": [
"Alarm7103F465",
"Arn"
]
}
}
},
"alarmLambdaFeatureAliasaliasNameAlarmFeatureAlarmPermission6A0A5797": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Ref": "alarmLambdaFeatureAliasaliasName16F91D34"
},
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
"SourceAccount": {
"Ref": "AWS::AccountId"
},
"SourceArn": {
"Fn::GetAtt": [
"AlarmFeature9DD74C42",
"Arn"
]
}
}
},
"alarmLambdaFeatureAlarmAlarmPermissionCF637A1C": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"alarmLambdaFeatureD560800F",
"Arn"
]
},
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
"SourceAccount": {
"Ref": "AWS::AccountId"
},
"SourceArn": {
"Fn::GetAtt": [
"Alarm7103F465",
"Arn"
]
}
}
},
"alarmLambdaFeatureAlarmFeatureAlarmPermission7032FB2D": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"alarmLambdaFeatureD560800F",
"Arn"
]
},
"Principal": "lambda.alarms.cloudwatch.amazonaws.com",
"SourceAccount": {
"Ref": "AWS::AccountId"
},
"SourceArn": {
"Fn::GetAtt": [
"AlarmFeature9DD74C42",
"Arn"
]
}
}
},
"AlarmFeature9DD74C42": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ActionsEnabled": true,
"AlarmActions": [
{
"Ref": "alarmLambdaFeatureCurrentVersionCF39751979501d2f67eaf906b2ef0c378303873b"
},
{
"Ref": "alarmLambdaFeatureAliasaliasName16F91D34"
},
{
"Fn::GetAtt": [
"alarmLambdaFeatureD560800F",
"Arn"
]
}
],
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "FunctionName",
"Value": {
"Ref": "inAlarmLambdaFeature6C78D351"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "Errors",
"Namespace": "AWS/Lambda",
"Period": 60,
"Statistic": "Sum",
"Threshold": 1,
"TreatMissingData": "notBreaching"
}
}
},
"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."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading