@digitraffic/common 2026.8.31-1 → 2026.8.31-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { App } from "aws-cdk-lib";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { DigitrafficStack } from "../../../aws/infra/stack/stack.js";
|
|
4
|
+
import { EnvKeys } from "../../../aws/runtime/environment.js";
|
|
5
|
+
import { TrafficType } from "../../../types/traffictype.js";
|
|
6
|
+
function createStack(secretId) {
|
|
7
|
+
const configuration = {
|
|
8
|
+
shortName: "VS",
|
|
9
|
+
trafficType: TrafficType.ROAD,
|
|
10
|
+
secretId,
|
|
11
|
+
alarmTopicArn: "",
|
|
12
|
+
warningTopicArn: "",
|
|
13
|
+
production: false,
|
|
14
|
+
stackProps: {},
|
|
15
|
+
};
|
|
16
|
+
return new DigitrafficStack(new App(), "TestStack", configuration);
|
|
17
|
+
}
|
|
18
|
+
describe("DigitrafficStack.createDefaultLambdaEnvironment", () => {
|
|
19
|
+
test("includes the application name without a secret", () => {
|
|
20
|
+
expect(createStack().createDefaultLambdaEnvironment("variable-signs")).toEqual({
|
|
21
|
+
[EnvKeys.APP_NAME]: "road-vs",
|
|
22
|
+
DB_APPLICATION: "variable-signs",
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
test("preserves the secret configuration", () => {
|
|
26
|
+
expect(createStack("test-secret").createDefaultLambdaEnvironment("variable-signs")).toEqual({
|
|
27
|
+
[EnvKeys.APP_NAME]: "road-vs",
|
|
28
|
+
DB_APPLICATION: "variable-signs",
|
|
29
|
+
SECRET_ID: "test-secret",
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=stack.test.js.map
|
|
@@ -3,6 +3,8 @@ import { SecurityGroup, Vpc } from "aws-cdk-lib/aws-ec2";
|
|
|
3
3
|
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
|
4
4
|
import { Topic } from "aws-cdk-lib/aws-sns";
|
|
5
5
|
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
6
|
+
import { kebabCase } from "es-toolkit";
|
|
7
|
+
import { EnvKeys } from "../../runtime/environment.js";
|
|
6
8
|
import { StackCheckingAspect } from "./stack-checking-aspect.js";
|
|
7
9
|
const SSM_ROOT = "/digitraffic";
|
|
8
10
|
export const SOLUTION_KEY = "Solution";
|
|
@@ -46,14 +48,13 @@ export class DigitrafficStack extends Stack {
|
|
|
46
48
|
return this.createDefaultLambdaEnvironment(this.configuration.shortName);
|
|
47
49
|
}
|
|
48
50
|
createDefaultLambdaEnvironment(dbApplication) {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
51
|
+
return {
|
|
52
|
+
[EnvKeys.APP_NAME]: `${this.configuration.trafficType.toLowerCase()}-${kebabCase(this.configuration.shortName)}`,
|
|
53
|
+
DB_APPLICATION: dbApplication,
|
|
54
|
+
...(this.configuration.secretId
|
|
55
|
+
? { SECRET_ID: this.configuration.secretId }
|
|
56
|
+
: {}),
|
|
57
|
+
};
|
|
57
58
|
}
|
|
58
59
|
getSecret() {
|
|
59
60
|
if (this.secret === undefined) {
|