diff --git a/notificationworkerlambda/cdk/lib/__snapshots__/senderworker.test.ts.snap b/notificationworkerlambda/cdk/lib/__snapshots__/senderworker.test.ts.snap index 3033e71dc..00678ace5 100644 --- a/notificationworkerlambda/cdk/lib/__snapshots__/senderworker.test.ts.snap +++ b/notificationworkerlambda/cdk/lib/__snapshots__/senderworker.test.ts.snap @@ -510,6 +510,39 @@ Object { }, "Type": "AWS::CloudWatch::Alarm", }, + "androidSenderTooFewInvocationsAlarmC306ECD5": Object { + "Properties": Object { + "ActionsEnabled": false, + "AlarmActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "AlarmDescription": "Triggers if the android sender lambda is not frequently invoked in PROD.", + "ComparisonOperator": "LessThanOrEqualToThreshold", + "Dimensions": Array [ + Object { + "Name": "FunctionName", + "Value": Object { + "Ref": "androidSenderLambdaCtr85CB623B", + }, + }, + ], + "EvaluationPeriods": 1, + "MetricName": "Invocations", + "Namespace": "AWS/Lambda", + "OKActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "Period": 360, + "Statistic": "Sum", + "Threshold": 0, + "TreatMissingData": "breaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, "androidbetaExecutionRoleFA113395": Object { "Properties": Object { "AssumeRolePolicyDocument": Object { @@ -947,6 +980,39 @@ Object { }, "Type": "AWS::CloudWatch::Alarm", }, + "androidbetaSenderTooFewInvocationsAlarm7B50CD4B": Object { + "Properties": Object { + "ActionsEnabled": false, + "AlarmActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "AlarmDescription": "Triggers if the android-beta sender lambda is not frequently invoked in PROD.", + "ComparisonOperator": "LessThanOrEqualToThreshold", + "Dimensions": Array [ + Object { + "Name": "FunctionName", + "Value": Object { + "Ref": "androidbetaSenderLambdaCtrB3CF7FC4", + }, + }, + ], + "EvaluationPeriods": 1, + "MetricName": "Invocations", + "Namespace": "AWS/Lambda", + "OKActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "Period": 360, + "Statistic": "Sum", + "Threshold": 0, + "TreatMissingData": "breaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, "androideditionExecutionRoleDEF8ADAE": Object { "Properties": Object { "AssumeRolePolicyDocument": Object { @@ -1384,6 +1450,39 @@ Object { }, "Type": "AWS::CloudWatch::Alarm", }, + "androideditionSenderTooFewInvocationsAlarmE4AB00FB": Object { + "Properties": Object { + "ActionsEnabled": false, + "AlarmActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "AlarmDescription": "Triggers if the android-edition sender lambda is not frequently invoked in PROD.", + "ComparisonOperator": "LessThanOrEqualToThreshold", + "Dimensions": Array [ + Object { + "Name": "FunctionName", + "Value": Object { + "Ref": "androideditionSenderLambdaCtrF0169D16", + }, + }, + ], + "EvaluationPeriods": 1, + "MetricName": "Invocations", + "Namespace": "AWS/Lambda", + "OKActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "Period": 360, + "Statistic": "Sum", + "Threshold": 0, + "TreatMissingData": "breaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, "iosExecutionRoleEE25DF12": Object { "Properties": Object { "AssumeRolePolicyDocument": Object { @@ -1821,6 +1920,39 @@ Object { }, "Type": "AWS::CloudWatch::Alarm", }, + "iosSenderTooFewInvocationsAlarm14117FE9": Object { + "Properties": Object { + "ActionsEnabled": false, + "AlarmActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "AlarmDescription": "Triggers if the ios sender lambda is not frequently invoked in PROD.", + "ComparisonOperator": "LessThanOrEqualToThreshold", + "Dimensions": Array [ + Object { + "Name": "FunctionName", + "Value": Object { + "Ref": "iosSenderLambdaCtr6053C1F8", + }, + }, + ], + "EvaluationPeriods": 1, + "MetricName": "Invocations", + "Namespace": "AWS/Lambda", + "OKActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "Period": 360, + "Statistic": "Sum", + "Threshold": 0, + "TreatMissingData": "breaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, "ioseditionExecutionRole61247F06": Object { "Properties": Object { "AssumeRolePolicyDocument": Object { @@ -2258,6 +2390,39 @@ Object { }, "Type": "AWS::CloudWatch::Alarm", }, + "ioseditionSenderTooFewInvocationsAlarmD32BB28C": Object { + "Properties": Object { + "ActionsEnabled": false, + "AlarmActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "AlarmDescription": "Triggers if the ios-edition sender lambda is not frequently invoked in PROD.", + "ComparisonOperator": "LessThanOrEqualToThreshold", + "Dimensions": Array [ + Object { + "Name": "FunctionName", + "Value": Object { + "Ref": "ioseditionSenderLambdaCtr2410D4D7", + }, + }, + ], + "EvaluationPeriods": 1, + "MetricName": "Invocations", + "Namespace": "AWS/Lambda", + "OKActions": Array [ + Object { + "Ref": "AlarmTopicArn", + }, + ], + "Period": 360, + "Statistic": "Sum", + "Threshold": 0, + "TreatMissingData": "breaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, }, } `; diff --git a/notificationworkerlambda/cdk/lib/senderworker.ts b/notificationworkerlambda/cdk/lib/senderworker.ts index 4034c04a7..a47bdeab6 100644 --- a/notificationworkerlambda/cdk/lib/senderworker.ts +++ b/notificationworkerlambda/cdk/lib/senderworker.ts @@ -147,7 +147,7 @@ class SenderWorker extends cdkcore.Construct { senderErrorAlarm.addAlarmAction(snsTopicAction) senderErrorAlarm.addOkAction(snsTopicAction) - if (scope.stage === 'CODE') { + if (scope.stage !== 'CODE') { const senderTooFewInvocationsAlarm = new cloudwatch.Alarm(this, 'SenderTooFewInvocationsAlarm', { alarmDescription: `Triggers if the ${id} sender lambda is not frequently invoked in ${scope.stage}.`, comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,