skuba 8.0.1-dive-migration-20240325115531 → 8.0.1

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.
Files changed (28) hide show
  1. package/README.md +3 -3
  2. package/jest/transform.js +2 -2
  3. package/lib/api/net/waitFor.d.ts +3 -3
  4. package/package.json +7 -7
  5. package/template/express-rest-api/.buildkite/pipeline.yml +3 -2
  6. package/template/express-rest-api/Dockerfile.dev-deps +3 -1
  7. package/template/express-rest-api/package.json +3 -2
  8. package/template/greeter/.buildkite/pipeline.yml +4 -1
  9. package/template/greeter/Dockerfile +3 -1
  10. package/template/greeter/package.json +1 -1
  11. package/template/koa-rest-api/.buildkite/pipeline.yml +3 -2
  12. package/template/koa-rest-api/Dockerfile.dev-deps +3 -1
  13. package/template/koa-rest-api/package.json +7 -6
  14. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +3 -2
  15. package/template/lambda-sqs-worker/Dockerfile +3 -1
  16. package/template/lambda-sqs-worker/package.json +4 -4
  17. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +3 -2
  18. package/template/lambda-sqs-worker-cdk/Dockerfile +3 -1
  19. package/template/lambda-sqs-worker-cdk/cdk.json +0 -23
  20. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +6 -6
  21. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +18 -20
  22. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +15 -14
  23. package/template/lambda-sqs-worker-cdk/infra/config.ts +41 -0
  24. package/template/lambda-sqs-worker-cdk/infra/index.ts +2 -5
  25. package/template/lambda-sqs-worker-cdk/package.json +2 -2
  26. package/template/oss-npm-package/.github/workflows/release.yml +2 -1
  27. package/template/oss-npm-package/.github/workflows/validate.yml +2 -1
  28. package/template/lambda-sqs-worker-cdk/shared/context-types.ts +0 -22
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  ---
4
4
 
5
- [![GitHub Release](https://github.com/seek-oss/skuba/workflows/Release/badge.svg?branch=master)](https://github.com/seek-oss/skuba/actions?query=workflow%3ARelease)
6
- [![GitHub Validate](https://github.com/seek-oss/skuba/workflows/Validate/badge.svg?branch=master)](https://github.com/seek-oss/skuba/actions?query=workflow%3AValidate)
7
- [![Node.js version](https://img.shields.io/badge/node-%3E%3D%2018.12-brightgreen)](https://nodejs.org/en/)
5
+ [![GitHub Release](https://github.com/seek-oss/skuba/workflows/Release/badge.svg?branch=main)](https://github.com/seek-oss/skuba/actions?query=workflow%3ARelease)
6
+ [![GitHub Validate](https://github.com/seek-oss/skuba/workflows/Validate/badge.svg?branch=main)](https://github.com/seek-oss/skuba/actions?query=workflow%3AValidate)
7
+ [![Node.js version](https://img.shields.io/badge/node-%3E%3D%2018.18-brightgreen)](https://nodejs.org/en/)
8
8
  [![npm package](https://img.shields.io/npm/v/skuba)](https://www.npmjs.com/package/skuba)
9
9
 
10
10
  ---
package/jest/transform.js CHANGED
@@ -18,15 +18,15 @@ const maybeTsConfig = tryParseTsConfig();
18
18
  const isolatedModules = maybeTsConfig?.options.isolatedModules ?? true;
19
19
 
20
20
  const BROKEN_MODULE_RESOLUTIONS = new Set([
21
+ ModuleResolutionKind.Bundler,
21
22
  ModuleResolutionKind.Node16,
22
23
  ModuleResolutionKind.NodeNext,
23
24
  ]);
24
25
 
25
26
  /**
26
- * Passing through `Node16` or `NodeNext` seems to break `ts-jest`.
27
+ * Passing through these module resolutions seems to break `ts-jest`.
27
28
  *
28
29
  * ```
29
- * error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.
30
30
  * error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'.
31
31
  * ```
32
32
  *
@@ -6,7 +6,7 @@ import { type SocketAddress } from './socket';
6
6
  * `timeout` is reached.
7
7
  */
8
8
  export declare const waitFor: ({ host, port, resolveCompose, timeout, }: {
9
- host?: string | undefined;
9
+ host?: string;
10
10
  port: number;
11
11
  /**
12
12
  * Whether to treat the `host` and `port` arguments as a private Docker
@@ -17,6 +17,6 @@ export declare const waitFor: ({ host, port, resolveCompose, timeout, }: {
17
17
  * - Enabled locally, when the application is running directly on the machine
18
18
  * - Disabled in CI, when running in a container on the Docker Compose network
19
19
  */
20
- resolveCompose?: boolean | undefined;
21
- timeout?: number | undefined;
20
+ resolveCompose?: boolean;
21
+ timeout?: number;
22
22
  }) => Promise<SocketAddress>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skuba",
3
- "version": "8.0.1-dive-migration-20240325115531",
3
+ "version": "8.0.1",
4
4
  "private": false,
5
5
  "description": "SEEK development toolkit for backend applications and packages",
6
6
  "homepage": "https://github.com/seek-oss/skuba#readme",
@@ -55,7 +55,7 @@
55
55
  "@octokit/graphql": "^8.0.0",
56
56
  "@octokit/graphql-schema": "^15.3.0",
57
57
  "@octokit/rest": "^20.0.0",
58
- "@octokit/types": "^12.0.0",
58
+ "@octokit/types": "^13.0.0",
59
59
  "@types/jest": "^29.0.0",
60
60
  "@types/node": ">=18.12",
61
61
  "chalk": "^4.1.0",
@@ -65,7 +65,7 @@
65
65
  "ejs": "^3.1.6",
66
66
  "enquirer": "^2.3.6",
67
67
  "esbuild": "~0.20.0",
68
- "eslint": "^8.11.0",
68
+ "eslint": "^8.56.0",
69
69
  "execa": "^5.0.0",
70
70
  "fast-glob": "^3.3.2",
71
71
  "fs-extra": "^11.0.0",
@@ -100,7 +100,7 @@
100
100
  "typescript": "~5.4.0",
101
101
  "validate-npm-package-name": "^5.0.0",
102
102
  "zod": "^3.22.4",
103
- "eslint-config-skuba": "4.0.1-dive-migration-20240325115531"
103
+ "eslint-config-skuba": "4.0.0"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@changesets/cli": "2.27.1",
@@ -119,7 +119,7 @@
119
119
  "@types/supertest": "6.0.2",
120
120
  "@types/validate-npm-package-name": "4.0.2",
121
121
  "enhanced-resolve": "5.15.0",
122
- "express": "4.18.2",
122
+ "express": "4.19.2",
123
123
  "fastify": "4.26.1",
124
124
  "jest-diff": "29.7.0",
125
125
  "jsonfile": "6.1.0",
@@ -132,14 +132,14 @@
132
132
  "type-fest": "2.19.0"
133
133
  },
134
134
  "peerDependencies": {
135
- "skuba-dive": "2.0.1-dive-migration-20240325115531"
135
+ "skuba-dive": "1 || 2"
136
136
  },
137
137
  "peerDependenciesMeta": {
138
138
  "skuba-dive": {
139
139
  "optional": true
140
140
  }
141
141
  },
142
- "packageManager": "pnpm@8.15.5",
142
+ "packageManager": "pnpm@8.15.6",
143
143
  "engines": {
144
144
  "node": ">=18.18.0"
145
145
  },
@@ -9,9 +9,10 @@ configs:
9
9
  NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
10
10
 
11
11
  - &docker-ecr-cache
12
- seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
12
+ seek-oss/docker-ecr-cache#v2.2.0: &docker-ecr-cache-defaults
13
13
  cache-on:
14
14
  - .npmrc
15
+ - package.json#.packageManager
15
16
  - pnpm-lock.yaml
16
17
  dockerfile: Dockerfile.dev-deps
17
18
  secrets: id=npm,src=tmp/.npmrc
@@ -37,7 +38,7 @@ steps:
37
38
  plugins:
38
39
  - *aws-sm
39
40
  - *private-npm
40
- - seek-oss/docker-ecr-cache#v2.1.1:
41
+ - seek-oss/docker-ecr-cache#v2.2.0:
41
42
  <<: *docker-ecr-cache-defaults
42
43
  skip-pull-from-cache: true
43
44
 
@@ -2,7 +2,9 @@
2
2
 
3
3
  FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
4
4
 
5
- RUN corepack enable pnpm
5
+ RUN --mount=type=bind,source=package.json,target=package.json \
6
+ corepack enable pnpm && corepack install
7
+
6
8
  RUN pnpm config set store-dir /root/.pnpm-store
7
9
 
8
10
  WORKDIR /workdir
@@ -20,11 +20,12 @@
20
20
  "@types/express": "^4.17.13",
21
21
  "@types/node": "^20.9.0",
22
22
  "@types/supertest": "^6.0.0",
23
- "pino-pretty": "^10.0.0",
23
+ "mime": "^4.0.1",
24
+ "pino-pretty": "^11.0.0",
24
25
  "skuba": "*",
25
26
  "supertest": "^6.1.6"
26
27
  },
27
- "packageManager": "pnpm@8.15.5",
28
+ "packageManager": "pnpm@8.15.6",
28
29
  "engines": {
29
30
  "node": ">=20"
30
31
  }
@@ -1,6 +1,8 @@
1
1
  agents:
2
2
  queue: <%- prodBuildkiteQueueName %>
3
3
 
4
+ # Allow conditional unblock + dodgy CI stuffs
5
+
4
6
  configs:
5
7
  plugins:
6
8
  - &aws-sm
@@ -9,9 +11,10 @@ configs:
9
11
  NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
10
12
 
11
13
  - &docker-ecr-cache
12
- seek-oss/docker-ecr-cache#v2.1.1:
14
+ seek-oss/docker-ecr-cache#v2.2.0:
13
15
  cache-on:
14
16
  - .npmrc
17
+ - package.json#.packageManager
15
18
  - pnpm-lock.yaml
16
19
  secrets: id=npm,src=tmp/.npmrc
17
20
 
@@ -2,7 +2,9 @@
2
2
 
3
3
  FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
4
4
 
5
- RUN corepack enable pnpm
5
+ RUN --mount=type=bind,source=package.json,target=package.json \
6
+ corepack enable pnpm && corepack install
7
+
6
8
  RUN pnpm config set store-dir /root/.pnpm-store
7
9
 
8
10
  WORKDIR /workdir
@@ -18,7 +18,7 @@
18
18
  "@types/node": "^20.9.0",
19
19
  "skuba": "*"
20
20
  },
21
- "packageManager": "pnpm@8.15.5",
21
+ "packageManager": "pnpm@8.15.6",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  }
@@ -9,9 +9,10 @@ configs:
9
9
  NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
10
10
 
11
11
  - &docker-ecr-cache
12
- seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
12
+ seek-oss/docker-ecr-cache#v2.2.0: &docker-ecr-cache-defaults
13
13
  cache-on:
14
14
  - .npmrc
15
+ - package.json#.packageManager
15
16
  - pnpm-lock.yaml
16
17
  dockerfile: Dockerfile.dev-deps
17
18
  secrets: id=npm,src=tmp/.npmrc
@@ -37,7 +38,7 @@ steps:
37
38
  plugins:
38
39
  - *aws-sm
39
40
  - *private-npm
40
- - seek-oss/docker-ecr-cache#v2.1.1:
41
+ - seek-oss/docker-ecr-cache#v2.2.0:
41
42
  <<: *docker-ecr-cache-defaults
42
43
  skip-pull-from-cache: true
43
44
 
@@ -2,7 +2,9 @@
2
2
 
3
3
  FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
4
4
 
5
- RUN corepack enable pnpm
5
+ RUN --mount=type=bind,source=package.json,target=package.json \
6
+ corepack enable pnpm && corepack install
7
+
6
8
  RUN pnpm config set store-dir /root/.pnpm-store
7
9
 
8
10
  WORKDIR /workdir
@@ -15,11 +15,11 @@
15
15
  "@koa/router": "^12.0.0",
16
16
  "@opentelemetry/api": "^1.1.0",
17
17
  "@opentelemetry/core": "^1.18.1",
18
- "@opentelemetry/exporter-trace-otlp-grpc": "^0.49.0",
19
- "@opentelemetry/instrumentation-aws-sdk": "^0.39.0",
20
- "@opentelemetry/instrumentation-http": "^0.49.0",
18
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.50.0",
19
+ "@opentelemetry/instrumentation-aws-sdk": "^0.40.0",
20
+ "@opentelemetry/instrumentation-http": "^0.50.0",
21
21
  "@opentelemetry/propagator-b3": "^1.18.1",
22
- "@opentelemetry/sdk-node": "^0.49.0",
22
+ "@opentelemetry/sdk-node": "^0.50.0",
23
23
  "@seek/logger": "^6.0.0",
24
24
  "aws-sdk": "^2.1039.0",
25
25
  "hot-shots": "^10.0.0",
@@ -39,11 +39,12 @@
39
39
  "@types/node": "^20.9.0",
40
40
  "@types/supertest": "^6.0.0",
41
41
  "chance": "^1.1.8",
42
- "pino-pretty": "^10.0.0",
42
+ "mime": "^4.0.1",
43
+ "pino-pretty": "^11.0.0",
43
44
  "skuba": "*",
44
45
  "supertest": "^6.1.6"
45
46
  },
46
- "packageManager": "pnpm@8.15.5",
47
+ "packageManager": "pnpm@8.15.6",
47
48
  "engines": {
48
49
  "node": ">=20"
49
50
  }
@@ -9,9 +9,10 @@ configs:
9
9
  NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
10
10
 
11
11
  - &docker-ecr-cache
12
- seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
12
+ seek-oss/docker-ecr-cache#v2.2.0: &docker-ecr-cache-defaults
13
13
  cache-on:
14
14
  - .npmrc
15
+ - package.json#.packageManager
15
16
  - pnpm-lock.yaml
16
17
  secrets: id=npm,src=tmp/.npmrc
17
18
 
@@ -81,7 +82,7 @@ steps:
81
82
  plugins:
82
83
  - *aws-sm
83
84
  - *private-npm
84
- - seek-oss/docker-ecr-cache#v2.1.1:
85
+ - seek-oss/docker-ecr-cache#v2.2.0:
85
86
  <<: *docker-ecr-cache-defaults
86
87
  skip-pull-from-cache: true
87
88
 
@@ -2,7 +2,9 @@
2
2
 
3
3
  FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
4
4
 
5
- RUN corepack enable pnpm
5
+ RUN --mount=type=bind,source=package.json,target=package.json \
6
+ corepack enable pnpm && corepack install
7
+
6
8
  RUN pnpm config set store-dir /root/.pnpm-store
7
9
 
8
10
  WORKDIR /workdir
@@ -27,17 +27,17 @@
27
27
  "@types/aws-lambda": "^8.10.84",
28
28
  "@types/chance": "^1.1.3",
29
29
  "@types/node": "^20.9.0",
30
- "aws-sdk-client-mock": "^3.0.0",
31
- "aws-sdk-client-mock-jest": "^3.0.0",
30
+ "aws-sdk-client-mock": "^4.0.0",
31
+ "aws-sdk-client-mock-jest": "^4.0.0",
32
32
  "chance": "^1.1.8",
33
- "pino-pretty": "^10.0.0",
33
+ "pino-pretty": "^11.0.0",
34
34
  "serverless": "^3.37.0",
35
35
  "serverless-plugin-canary-deployments": "^0.8.0",
36
36
  "serverless-plugin-datadog": "^5.12.0",
37
37
  "serverless-prune-plugin": "^2.0.0",
38
38
  "skuba": "*"
39
39
  },
40
- "packageManager": "pnpm@8.15.5",
40
+ "packageManager": "pnpm@8.15.6",
41
41
  "engines": {
42
42
  "node": ">=20"
43
43
  }
@@ -9,9 +9,10 @@ configs:
9
9
  NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
10
10
 
11
11
  - &docker-ecr-cache
12
- seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
12
+ seek-oss/docker-ecr-cache#v2.2.0: &docker-ecr-cache-defaults
13
13
  cache-on:
14
14
  - .npmrc
15
+ - package.json#.packageManager
15
16
  - pnpm-lock.yaml
16
17
  secrets: id=npm,src=tmp/.npmrc
17
18
 
@@ -77,7 +78,7 @@ steps:
77
78
  plugins:
78
79
  - *aws-sm
79
80
  - *private-npm
80
- - seek-oss/docker-ecr-cache#v2.1.1:
81
+ - seek-oss/docker-ecr-cache#v2.2.0:
81
82
  <<: *docker-ecr-cache-defaults
82
83
  skip-pull-from-cache: true
83
84
 
@@ -5,7 +5,9 @@ FROM --platform=<%- platformName %> node:20-alpine AS dev-deps
5
5
  # Needed for cdk
6
6
  RUN apk add --no-cache bash
7
7
 
8
- RUN corepack enable pnpm
8
+ RUN --mount=type=bind,source=package.json,target=package.json \
9
+ corepack enable pnpm && corepack install
10
+
9
11
  RUN pnpm config set store-dir /root/.pnpm-store
10
12
 
11
13
  WORKDIR /workdir
@@ -1,28 +1,5 @@
1
1
  {
2
2
  "app": "pnpm exec skuba node infra/index.ts",
3
- "context": {
4
- "global": {
5
- "appName": "<%- serviceName %>"
6
- },
7
- "dev": {
8
- "workerLambda": {
9
- "reservedConcurrency": 2,
10
- "environment": {
11
- "ENVIRONMENT": "dev"
12
- }
13
- },
14
- "sourceSnsTopicArn": "TODO: sourceSnsTopicArn"
15
- },
16
- "prod": {
17
- "workerLambda": {
18
- "reservedConcurrency": 20,
19
- "environment": {
20
- "ENVIRONMENT": "prod"
21
- }
22
- },
23
- "sourceSnsTopicArn": "TODO: sourceSnsTopicArn"
24
- }
25
- },
26
3
  "progress": "events",
27
4
  "watch": {
28
5
  "include": "src/**/*.ts",
@@ -934,7 +934,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
934
934
  "RedrivePolicy": {
935
935
  "deadLetterTargetArn": {
936
936
  "Fn::GetAtt": [
937
- "workerqueuedlq42262778",
937
+ "workerqueuedeadletters83F3505C",
938
938
  "Arn",
939
939
  ],
940
940
  },
@@ -997,7 +997,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
997
997
  },
998
998
  "Type": "AWS::SNS::Subscription",
999
999
  },
1000
- "workerqueuedlq42262778": {
1000
+ "workerqueuedeadletters83F3505C": {
1001
1001
  "DeletionPolicy": "Delete",
1002
1002
  "Properties": {
1003
1003
  "KmsMasterKeyId": {
@@ -1006,7 +1006,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
1006
1006
  "Arn",
1007
1007
  ],
1008
1008
  },
1009
- "QueueName": "serviceName-dlq",
1009
+ "QueueName": "serviceName-dead-letters",
1010
1010
  },
1011
1011
  "Type": "AWS::SQS::Queue",
1012
1012
  "UpdateReplacePolicy": "Delete",
@@ -1976,7 +1976,7 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
1976
1976
  "RedrivePolicy": {
1977
1977
  "deadLetterTargetArn": {
1978
1978
  "Fn::GetAtt": [
1979
- "workerqueuedlq42262778",
1979
+ "workerqueuedeadletters83F3505C",
1980
1980
  "Arn",
1981
1981
  ],
1982
1982
  },
@@ -2039,7 +2039,7 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
2039
2039
  },
2040
2040
  "Type": "AWS::SNS::Subscription",
2041
2041
  },
2042
- "workerqueuedlq42262778": {
2042
+ "workerqueuedeadletters83F3505C": {
2043
2043
  "DeletionPolicy": "Delete",
2044
2044
  "Properties": {
2045
2045
  "KmsMasterKeyId": {
@@ -2048,7 +2048,7 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
2048
2048
  "Arn",
2049
2049
  ],
2050
2050
  },
2051
- "QueueName": "serviceName-dlq",
2051
+ "QueueName": "serviceName-dead-letters",
2052
2052
  },
2053
2053
  "Type": "AWS::SQS::Queue",
2054
2054
  "UpdateReplacePolicy": "Delete",
@@ -1,22 +1,6 @@
1
1
  import { App, aws_sns } from 'aws-cdk-lib';
2
2
  import { Template } from 'aws-cdk-lib/assertions';
3
3
 
4
- import cdkJson from '../cdk.json';
5
-
6
- import { AppStack } from './appStack';
7
-
8
- const contexts = [
9
- {
10
- stage: 'dev',
11
- ...cdkJson.context,
12
- },
13
-
14
- {
15
- stage: 'prod',
16
- ...cdkJson.context,
17
- },
18
- ];
19
-
20
4
  const currentDate = '1212-12-12T12:12:12.121Z';
21
5
 
22
6
  jest.useFakeTimers({
@@ -31,14 +15,28 @@ jest.useFakeTimers({
31
15
  now: new Date(currentDate),
32
16
  });
33
17
 
34
- it.each(contexts)(
35
- 'returns expected CloudFormation stack for $stage',
36
- (context) => {
18
+ const originalEnv = process.env.ENVIRONMENT;
19
+
20
+ afterAll(() => {
21
+ process.env.ENVIRONMENT = originalEnv;
22
+ });
23
+
24
+ afterEach(() => {
25
+ jest.resetModules();
26
+ });
27
+
28
+ it.each(['dev', 'prod'])(
29
+ 'returns expected CloudFormation stack for %s',
30
+ async (env) => {
31
+ process.env.ENVIRONMENT = env;
32
+
33
+ const { AppStack } = await import('./appStack');
34
+
37
35
  jest
38
36
  .spyOn(aws_sns.Topic, 'fromTopicArn')
39
37
  .mockImplementation((scope, id) => new aws_sns.Topic(scope, id));
40
38
 
41
- const app = new App({ context });
39
+ const app = new App();
42
40
 
43
41
  const stack = new AppStack(app, 'appStack');
44
42
 
@@ -15,15 +15,12 @@ import {
15
15
  } from 'aws-cdk-lib';
16
16
  import type { Construct } from 'constructs';
17
17
 
18
- import { EnvContextSchema, StageContextSchema } from '../shared/context-types';
18
+ import { config } from './config';
19
19
 
20
20
  export class AppStack extends Stack {
21
21
  constructor(scope: Construct, id: string, props?: StackProps) {
22
22
  super(scope, id, props);
23
23
 
24
- const stage = StageContextSchema.parse(this.node.tryGetContext('stage'));
25
- const context = EnvContextSchema.parse(this.node.tryGetContext(stage));
26
-
27
24
  const accountPrincipal = new aws_iam.AccountPrincipal(this.account);
28
25
 
29
26
  const kmsKey = new aws_kms.Key(this, 'kms-key', {
@@ -35,10 +32,14 @@ export class AppStack extends Stack {
35
32
 
36
33
  kmsKey.grantEncrypt(accountPrincipal);
37
34
 
38
- const deadLetterQueue = new aws_sqs.Queue(this, 'worker-queue-dlq', {
39
- queueName: '<%- serviceName %>-dlq',
40
- encryptionMasterKey: kmsKey,
41
- });
35
+ const deadLetterQueue = new aws_sqs.Queue(
36
+ this,
37
+ 'worker-queue-dead-letters',
38
+ {
39
+ queueName: '<%- serviceName %>-dead-letters',
40
+ encryptionMasterKey: kmsKey,
41
+ },
42
+ );
42
43
 
43
44
  const queue = new aws_sqs.Queue(this, 'worker-queue', {
44
45
  queueName: '<%- serviceName %>',
@@ -52,7 +53,7 @@ export class AppStack extends Stack {
52
53
  const topic = aws_sns.Topic.fromTopicArn(
53
54
  this,
54
55
  'source-topic',
55
- context.sourceSnsTopicArn,
56
+ config.sourceSnsTopicArn,
56
57
  );
57
58
 
58
59
  topic.addSubscription(new aws_sns_subscriptions.SqsSubscription(queue));
@@ -89,13 +90,13 @@ export class AppStack extends Stack {
89
90
  functionName: '<%- serviceName %>',
90
91
  environment: {
91
92
  ...defaultWorkerEnvironment,
92
- ...context.workerLambda.environment,
93
+ ...config.workerLambda.environment,
93
94
  },
94
95
  // https://github.com/aws/aws-cdk/issues/28237
95
96
  // This forces the lambda to be updated on every deployment
96
97
  // If you do not wish to use hotswap, you can remove the new Date().toISOString() from the description
97
98
  description: `Updated at ${new Date().toISOString()}`,
98
- reservedConcurrentExecutions: context.workerLambda.reservedConcurrency,
99
+ reservedConcurrentExecutions: config.workerLambda.reservedConcurrency,
99
100
  });
100
101
 
101
102
  const alias = worker.addAlias('live', {
@@ -104,7 +105,7 @@ export class AppStack extends Stack {
104
105
 
105
106
  alias.addEventSource(
106
107
  new aws_lambda_event_sources.SqsEventSource(queue, {
107
- maxConcurrency: context.workerLambda.reservedConcurrency,
108
+ maxConcurrency: config.workerLambda.reservedConcurrency,
108
109
  }),
109
110
  );
110
111
 
@@ -119,7 +120,7 @@ export class AppStack extends Stack {
119
120
  functionName: '<%- serviceName %>-pre-hook',
120
121
  environment: {
121
122
  ...defaultWorkerEnvironment,
122
- ...context.workerLambda.environment,
123
+ ...config.workerLambda.environment,
123
124
  FUNCTION_NAME_TO_INVOKE: worker.functionName,
124
125
  },
125
126
  },
@@ -138,7 +139,7 @@ export class AppStack extends Stack {
138
139
  functionName: '<%- serviceName %>-post-hook',
139
140
  environment: {
140
141
  ...defaultWorkerEnvironment,
141
- ...context.workerLambda.environment,
142
+ ...config.workerLambda.environment,
142
143
  FUNCTION_NAME_TO_PRUNE: worker.functionName,
143
144
  },
144
145
  },
@@ -0,0 +1,41 @@
1
+ import { z } from 'zod';
2
+
3
+ const environment = z.enum(['dev', 'prod']).parse(process.env.ENVIRONMENT);
4
+
5
+ type Environment = typeof environment;
6
+
7
+ export interface Config {
8
+ appName: string;
9
+ workerLambda: {
10
+ reservedConcurrency: number;
11
+ environment: {
12
+ ENVIRONMENT: Environment;
13
+ };
14
+ };
15
+ sourceSnsTopicArn: string;
16
+ }
17
+
18
+ export const configs: Record<Environment, Config> = {
19
+ dev: {
20
+ appName: '<%- serviceName %>',
21
+ workerLambda: {
22
+ reservedConcurrency: 2,
23
+ environment: {
24
+ ENVIRONMENT: 'dev',
25
+ },
26
+ },
27
+ sourceSnsTopicArn: 'TODO: sourceSnsTopicArn',
28
+ },
29
+ prod: {
30
+ appName: '<%- serviceName %>',
31
+ workerLambda: {
32
+ reservedConcurrency: 20,
33
+ environment: {
34
+ ENVIRONMENT: 'prod',
35
+ },
36
+ },
37
+ sourceSnsTopicArn: 'TODO: sourceSnsTopicArn',
38
+ },
39
+ };
40
+
41
+ export const config = configs[environment];
@@ -1,14 +1,11 @@
1
1
  import { App } from 'aws-cdk-lib';
2
2
 
3
- import { GlobalContextSchema } from '../shared/context-types';
4
-
5
3
  import { AppStack } from './appStack';
4
+ import { config } from './config';
6
5
 
7
6
  const app = new App();
8
7
 
9
- const context = GlobalContextSchema.parse(app.node.tryGetContext('global'));
10
-
11
8
  // eslint-disable-next-line no-new
12
9
  new AppStack(app, 'appStack', {
13
- stackName: context.appName,
10
+ stackName: config.appName,
14
11
  });
@@ -2,7 +2,7 @@
2
2
  "private": true,
3
3
  "license": "UNLICENSED",
4
4
  "scripts": {
5
- "deploy": "cdk deploy appStack --require-approval never --context stage=${ENVIRONMENT}",
5
+ "deploy": "cdk deploy appStack --require-approval never",
6
6
  "deploy:hotswap": "pnpm --silent deploy --hotswap",
7
7
  "deploy:watch": "pnpm --silent deploy:hotswap --watch",
8
8
  "format": "skuba format",
@@ -26,7 +26,7 @@
26
26
  "constructs": "^10.0.17",
27
27
  "skuba": "*"
28
28
  },
29
- "packageManager": "pnpm@8.15.5",
29
+ "packageManager": "pnpm@8.15.6",
30
30
  "engines": {
31
31
  "node": ">=20"
32
32
  }
@@ -15,6 +15,7 @@ jobs:
15
15
  contents: write
16
16
  id-token: write
17
17
  runs-on: ubuntu-latest
18
+ timeout-minutes: 20
18
19
  steps:
19
20
  - name: Check out repo
20
21
  uses: actions/checkout@v4
@@ -27,7 +28,7 @@ jobs:
27
28
  node-version: 20.x
28
29
 
29
30
  - name: Set up pnpm
30
- run: corepack enable pnpm
31
+ run: corepack enable pnpm && corepack install
31
32
 
32
33
  - name: Install dependencies
33
34
  run: pnpm install --frozen-lockfile
@@ -12,6 +12,7 @@ jobs:
12
12
  permissions:
13
13
  checks: write
14
14
  runs-on: ubuntu-latest
15
+ timeout-minutes: 20
15
16
  steps:
16
17
  - name: Check out repo
17
18
  uses: actions/checkout@v4
@@ -22,7 +23,7 @@ jobs:
22
23
  node-version: 20.x
23
24
 
24
25
  - name: Set up pnpm
25
- run: corepack enable pnpm
26
+ run: corepack enable pnpm && corepack install
26
27
 
27
28
  - name: Install dependencies
28
29
  run: pnpm install --frozen-lockfile
@@ -1,22 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- export const StageContextSchema = z.enum(['dev', 'prod']);
4
- export type StageContext = z.infer<typeof StageContextSchema>;
5
-
6
- export const EnvContextSchema = z.object({
7
- workerLambda: z.object({
8
- reservedConcurrency: z.number(),
9
- environment: z.object({
10
- ENVIRONMENT: z.string(),
11
- }),
12
- }),
13
- sourceSnsTopicArn: z.string(),
14
- });
15
-
16
- export type EnvContext = z.infer<typeof EnvContextSchema>;
17
-
18
- export const GlobalContextSchema = z.object({
19
- appName: z.string(),
20
- });
21
-
22
- export type GlobalContext = z.infer<typeof GlobalContextSchema>;