Skip to content

Commit 8811fc9

Browse files
committed
use human-readable function name for lambda
1 parent 632d4be commit 8811fc9

File tree

2 files changed

+53
-49
lines changed

2 files changed

+53
-49
lines changed

ab-testing/cdk/lib/__snapshots__/notificationLambda.test.ts.snap

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ exports[`The AB testing notification lambda stack > matches the CODE snapshot 1`
317317
"APP": "ab-testing-notification-lambda"
318318
}
319319
},
320+
"FunctionName": "ab-testing-notification-lambda-CODE",
320321
"Handler": "index.handler",
321322
"LoggingConfig": {
322323
"LogFormat": "JSON"
@@ -382,29 +383,8 @@ exports[`The AB testing notification lambda stack > matches the CODE snapshot 1`
382383
]
383384
}
384385
],
385-
"AlarmDescription": {
386-
"Fn::Join": [
387-
"",
388-
[
389-
{
390-
"Ref": "AbTestingNotificationLambda36F153E8"
391-
},
392-
" exceeded 0% error rate"
393-
]
394-
]
395-
},
396-
"AlarmName": {
397-
"Fn::Join": [
398-
"",
399-
[
400-
"High error percentage from ",
401-
{
402-
"Ref": "AbTestingNotificationLambda36F153E8"
403-
},
404-
" lambda in CODE"
405-
]
406-
]
407-
},
386+
"AlarmDescription": "Something went wrong notifying test owners of upcoming AB test expiries in the CODE AB Testing Notification Lambda. Please check the logs",
387+
"AlarmName": "AB Testing Notification Lambda Failures",
408388
"ComparisonOperator": "GreaterThanThreshold",
409389
"EvaluationPeriods": 1,
410390
"Metrics": [
@@ -465,6 +445,26 @@ exports[`The AB testing notification lambda stack > matches the CODE snapshot 1`
465445
"ReturnData": false
466446
}
467447
],
448+
"OKActions": [
449+
{
450+
"Fn::Join": [
451+
"",
452+
[
453+
"arn:aws:sns:eu-west-1:",
454+
{
455+
"Ref": "AWS::AccountId"
456+
},
457+
":",
458+
{
459+
"Fn::GetAtt": [
460+
"AbTestingNotificationSnsTopicB3559144",
461+
"TopicName"
462+
]
463+
}
464+
]
465+
]
466+
}
467+
],
468468
"Tags": [
469469
{
470470
"Key": "gu:cdk:version",
@@ -827,6 +827,7 @@ exports[`The AB testing notification lambda stack > matches the PROD snapshot 1`
827827
"APP": "ab-testing-notification-lambda"
828828
}
829829
},
830+
"FunctionName": "ab-testing-notification-lambda-PROD",
830831
"Handler": "index.handler",
831832
"LoggingConfig": {
832833
"LogFormat": "JSON"
@@ -952,29 +953,8 @@ exports[`The AB testing notification lambda stack > matches the PROD snapshot 1`
952953
]
953954
}
954955
],
955-
"AlarmDescription": {
956-
"Fn::Join": [
957-
"",
958-
[
959-
{
960-
"Ref": "AbTestingNotificationLambda36F153E8"
961-
},
962-
" exceeded 0% error rate"
963-
]
964-
]
965-
},
966-
"AlarmName": {
967-
"Fn::Join": [
968-
"",
969-
[
970-
"High error percentage from ",
971-
{
972-
"Ref": "AbTestingNotificationLambda36F153E8"
973-
},
974-
" lambda in PROD"
975-
]
976-
]
977-
},
956+
"AlarmDescription": "Something went wrong notifying test owners of upcoming AB test expiries in the PROD AB Testing Notification Lambda. Please check the logs",
957+
"AlarmName": "AB Testing Notification Lambda Failures",
978958
"ComparisonOperator": "GreaterThanThreshold",
979959
"EvaluationPeriods": 1,
980960
"Metrics": [
@@ -1035,6 +1015,26 @@ exports[`The AB testing notification lambda stack > matches the PROD snapshot 1`
10351015
"ReturnData": false
10361016
}
10371017
],
1018+
"OKActions": [
1019+
{
1020+
"Fn::Join": [
1021+
"",
1022+
[
1023+
"arn:aws:sns:eu-west-1:",
1024+
{
1025+
"Ref": "AWS::AccountId"
1026+
},
1027+
":",
1028+
{
1029+
"Fn::GetAtt": [
1030+
"AbTestingNotificationSnsTopicB3559144",
1031+
"TopicName"
1032+
]
1033+
}
1034+
]
1035+
]
1036+
}
1037+
],
10381038
"Tags": [
10391039
{
10401040
"Key": "gu:cdk:version",

ab-testing/cdk/lib/notificationLambda.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
1010
import { Runtime } from "aws-cdk-lib/aws-lambda";
1111
import { Subscription, SubscriptionProtocol, Topic } from "aws-cdk-lib/aws-sns";
1212

13-
const lambdaFunctionName = "ab-testing-notification-lambda";
13+
const appName = "ab-testing-notification-lambda";
1414

1515
const getEmailDomain = (stage: GuStackProps["stage"]) => {
1616
switch (stage) {
@@ -33,7 +33,7 @@ export class AbTestingNotificationLambda extends GuStack {
3333
};
3434

3535
const emailIdentity = new GuEmailIdentity(this, "EmailIdentity", {
36-
app: lambdaFunctionName,
36+
app: appName,
3737
domainName: getEmailDomain(props.stage),
3838
});
3939

@@ -53,13 +53,17 @@ export class AbTestingNotificationLambda extends GuStack {
5353
this,
5454
"AbTestingNotificationLambda",
5555
{
56-
app: lambdaFunctionName,
56+
functionName: `${appName}-${props.stage}`,
57+
app: appName,
5758
fileName: "lambda.zip",
5859
handler: "index.handler",
5960
rules: this.stage === "PROD" ? [runDailyRule] : [],
6061
monitoringConfiguration: {
6162
snsTopicName: snsTopic.topicName,
6263
toleratedErrorPercentage: 0,
64+
alarmName: "AB Testing Notification Lambda Failures",
65+
alarmDescription: `Something went wrong notifying test owners of upcoming AB test expiries in the ${props.stage} AB Testing Notification Lambda. Please check the logs`,
66+
okAction: true,
6367
},
6468
runtime: Runtime.NODEJS_22_X,
6569
environment: {

0 commit comments

Comments
 (0)