Skip to content

Commit 69c9473

Browse files
authored
Add riff-raff build id to ab-testing custom resource (#15070)
1 parent 76aa9d3 commit 69c9473

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ exports[`The ID5 Baton Lambda stack > matches the CODE snapshot 1`] = `
44
"gu:cdk:constructs": [],
55
"gu:cdk:version": "62.0.1"
66
},
7+
"Parameters": {
8+
"BuildId": {
9+
"Type": "String",
10+
"Description": "The riff-raff build id, automatically generated and provided by riff-raff"
11+
}
12+
},
713
"Resources": {
814
"InvokeDictionaryDeployLambda": {
915
"Type": "Custom::FastlyEdgeDictionaryDeploy",
@@ -24,7 +30,10 @@ exports[`The ID5 Baton Lambda stack > matches the CODE snapshot 1`] = `
2430
]
2531
]
2632
},
27-
"ServiceTimeout": "300"
33+
"ServiceTimeout": "300",
34+
"BuildId": {
35+
"Ref": "BuildId"
36+
}
2837
},
2938
"UpdateReplacePolicy": "Delete",
3039
"DeletionPolicy": "Delete"
@@ -39,6 +48,12 @@ exports[`The ID5 Baton Lambda stack > matches the PROD snapshot 1`] = `
3948
"gu:cdk:constructs": [],
4049
"gu:cdk:version": "62.0.1"
4150
},
51+
"Parameters": {
52+
"BuildId": {
53+
"Type": "String",
54+
"Description": "The riff-raff build id, automatically generated and provided by riff-raff"
55+
}
56+
},
4257
"Resources": {
4358
"InvokeDictionaryDeployLambda": {
4459
"Type": "Custom::FastlyEdgeDictionaryDeploy",
@@ -59,7 +74,10 @@ exports[`The ID5 Baton Lambda stack > matches the PROD snapshot 1`] = `
5974
]
6075
]
6176
},
62-
"ServiceTimeout": "300"
77+
"ServiceTimeout": "300",
78+
"BuildId": {
79+
"Ref": "BuildId"
80+
}
6381
},
6482
"UpdateReplacePolicy": "Delete",
6583
"DeletionPolicy": "Delete"

ab-testing/cdk/lib/abTestingConfig.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { GuStackProps } from "@guardian/cdk/lib/constructs/core/stack.js";
22
import { GuStack } from "@guardian/cdk/lib/constructs/core/stack.js";
33
import type { App } from "aws-cdk-lib";
4-
import { CustomResource, Duration } from "aws-cdk-lib";
4+
import { CfnParameter, CustomResource, Duration } from "aws-cdk-lib";
55
import { Function } from "aws-cdk-lib/aws-lambda";
66
import { lambdaFunctionName } from "./deploymentLambda.ts";
77

@@ -15,11 +15,21 @@ export class AbTestingConfig extends GuStack {
1515
`${lambdaFunctionName}-${this.stage}`,
1616
);
1717

18+
const buildId = new CfnParameter(this, "BuildId", {
19+
type: "String",
20+
description:
21+
"The riff-raff build id, automatically generated and provided by riff-raff",
22+
});
23+
1824
// Trigger the Lambda to run upon deployment
1925
new CustomResource(this, "InvokeDictionaryDeployLambda", {
2026
serviceToken: lambda.functionArn,
2127
serviceTimeout: Duration.minutes(5),
2228
resourceType: "Custom::FastlyEdgeDictionaryDeploy",
29+
properties: {
30+
/** Ensures the custom resource is invoked on every deploy */
31+
BuildId: buildId.valueAsString,
32+
},
2333
});
2434
}
2535
}

0 commit comments

Comments
 (0)