skuba 12.1.0-hoist-less-20250722131939 → 12.1.0-main-20250812041011
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.
- package/README.md +1 -2
- package/config/tsconfig.json +3 -2
- package/lib/cli/build/assets.js +1 -1
- package/lib/cli/build/assets.js.map +2 -2
- package/lib/cli/build/tsc.d.ts +5 -1
- package/lib/cli/build/tsc.js +12 -0
- package/lib/cli/build/tsc.js.map +3 -3
- package/lib/cli/init/getConfig.js +1 -1
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/lint/internal.js +1 -1
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +35 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.d.ts +4 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +162 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +2 -2
- package/lib/cli/node/index.js +8 -2
- package/lib/cli/node/index.js.map +2 -2
- package/lib/cli/start/index.js +8 -2
- package/lib/cli/start/index.js.map +2 -2
- package/lib/cli/test/index.d.ts +1 -1
- package/lib/cli/test/index.js +18 -4
- package/lib/cli/test/index.js.map +2 -2
- package/lib/utils/args.d.ts +2 -0
- package/lib/utils/args.js +5 -0
- package/lib/utils/args.js.map +2 -2
- package/package.json +16 -17
- package/template/base/_pnpm-workspace.yaml +1 -0
- package/template/base/jest.setup.ts +1 -1
- package/template/express-rest-api/.buildkite/pipeline.yml +6 -0
- package/template/express-rest-api/.env +1 -1
- package/template/express-rest-api/.gantry/dev.yml +5 -1
- package/template/express-rest-api/.gantry/prod.yml +5 -1
- package/template/express-rest-api/Dockerfile +1 -1
- package/template/express-rest-api/README.md +5 -5
- package/template/express-rest-api/gantry.apply.yml +17 -1
- package/template/express-rest-api/package.json +11 -5
- package/template/express-rest-api/src/api/healthCheck.ts +2 -2
- package/template/express-rest-api/src/config.ts +7 -7
- package/template/express-rest-api/src/framework/logging.ts +11 -7
- package/template/express-rest-api/src/framework/metrics.ts +1 -1
- package/template/express-rest-api/src/listen.ts +6 -0
- package/template/express-rest-api/src/tracing.ts +56 -0
- package/template/greeter/README.md +2 -2
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +6 -0
- package/template/koa-rest-api/.env +1 -1
- package/template/koa-rest-api/.gantry/dev.yml +3 -3
- package/template/koa-rest-api/.gantry/prod.yml +3 -3
- package/template/koa-rest-api/README.md +6 -6
- package/template/koa-rest-api/gantry.apply.yml +15 -3
- package/template/koa-rest-api/package.json +9 -10
- package/template/koa-rest-api/src/api/healthCheck.ts +2 -2
- package/template/koa-rest-api/src/config.ts +7 -7
- package/template/koa-rest-api/src/framework/logging.ts +12 -8
- package/template/koa-rest-api/src/framework/metrics.ts +1 -1
- package/template/koa-rest-api/src/framework/server.test.ts +7 -8
- package/template/koa-rest-api/src/framework/server.ts +1 -4
- package/template/koa-rest-api/src/listen.ts +6 -0
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +6 -2
- package/template/lambda-sqs-worker-cdk/.env +1 -1
- package/template/lambda-sqs-worker-cdk/README.md +8 -8
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +50 -10
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +5 -8
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +15 -5
- package/template/lambda-sqs-worker-cdk/infra/config.ts +30 -18
- package/template/lambda-sqs-worker-cdk/infra/index.ts +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +7 -7
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +91 -51
- package/template/lambda-sqs-worker-cdk/src/app.ts +7 -9
- package/template/lambda-sqs-worker-cdk/src/config.ts +11 -16
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +10 -5
- package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +44 -24
- package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +23 -11
- package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -4
- package/template/lambda-sqs-worker-cdk/src/testing/handler.ts +4 -1
- package/template/oss-npm-package/.github/workflows/release.yml +1 -1
- package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
DEPLOYMENT=local
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
deployment: dev
|
|
2
|
+
env: development
|
|
2
3
|
|
|
3
4
|
maxInstanceCount: 1
|
|
4
5
|
minInstanceCount: 1
|
|
@@ -7,5 +8,4 @@ minInstanceCount: 1
|
|
|
7
8
|
cloudwatchDashboardDisabled: true
|
|
8
9
|
|
|
9
10
|
openTelemetry:
|
|
10
|
-
|
|
11
|
-
enabled: false
|
|
11
|
+
enabled: true
|
|
@@ -29,7 +29,7 @@ It uses the [Koa] middleware framework and common SEEK packages.
|
|
|
29
29
|
Resource APIs enable synchronous interactions and serve as the backbone of SEEK's general service architecture.
|
|
30
30
|
|
|
31
31
|
The `koa-rest-api` template is modelled after a hypothetical service for posting and retrieving job advertisements.
|
|
32
|
-
It's stubbed out with in-memory [storage](src/storage) which can observed by standing up
|
|
32
|
+
It's stubbed out with in-memory [storage](src/storage) which can observed by standing up a deployment with multiple instances.
|
|
33
33
|
Storage is local to each instance, so load balancing across the instances may render a read inconsistent with a previous write.
|
|
34
34
|
This would be replaced with an external data store in production.
|
|
35
35
|
|
|
@@ -75,19 +75,19 @@ pnpm start:debug
|
|
|
75
75
|
|
|
76
76
|
This project is deployed through a [Buildkite pipeline](.buildkite/pipeline.yml).
|
|
77
77
|
|
|
78
|
-
- Commits to a feature branch can be deployed to the
|
|
79
|
-
- Commits to the default branch are automatically deployed to the
|
|
78
|
+
- Commits to a feature branch can be deployed to the development environment by unblocking a step in the Buildkite UI
|
|
79
|
+
- Commits to the default branch are automatically deployed to the development and production environments in sequence
|
|
80
80
|
|
|
81
81
|
To rapidly roll back a change,
|
|
82
82
|
retry an individual deployment step from the previous build in Buildkite.
|
|
83
|
-
Note that this will introduce drift between the head of the default Git branch and the live
|
|
83
|
+
Note that this will introduce drift between the head of the default Git branch and the live deployment;
|
|
84
84
|
use with caution and always follow up with a proper revert or fix in Git history.
|
|
85
85
|
|
|
86
86
|
## Support
|
|
87
87
|
|
|
88
88
|
### Dev
|
|
89
89
|
|
|
90
|
-
TODO: add support links for the dev
|
|
90
|
+
TODO: add support links for the dev deployment.
|
|
91
91
|
|
|
92
92
|
<!--
|
|
93
93
|
- CloudWatch dashboard
|
|
@@ -97,7 +97,7 @@ TODO: add support links for the dev environment.
|
|
|
97
97
|
|
|
98
98
|
### Prod
|
|
99
99
|
|
|
100
|
-
TODO: add support links for the prod
|
|
100
|
+
TODO: add support links for the prod deployment.
|
|
101
101
|
|
|
102
102
|
<!--
|
|
103
103
|
- CloudWatch dashboard
|
|
@@ -9,10 +9,14 @@ owner: '{{values "owner"}}'
|
|
|
9
9
|
image: '{{values "image"}}'
|
|
10
10
|
|
|
11
11
|
env:
|
|
12
|
-
|
|
13
|
-
OPENTELEMETRY_ENABLED: '{{.Values.openTelemetry.enabled | default false}}'
|
|
12
|
+
DEPLOYMENT: '{{values "deployment"}}'
|
|
14
13
|
SERVICE: '{{values "service"}}'
|
|
15
14
|
|
|
15
|
+
DD_ENV: '{{values "env"}}'
|
|
16
|
+
DD_SERVICE: '{{values "service"}}'
|
|
17
|
+
|
|
18
|
+
OPENTELEMETRY_ENABLED: '{{values "openTelemetry.enabled"}}'
|
|
19
|
+
|
|
16
20
|
{{if .Values.cloudwatchDashboardDisabled}}
|
|
17
21
|
cloudwatchDashboardDisabled: {{values "cloudwatchDashboardDisabled"}}
|
|
18
22
|
{{end}}
|
|
@@ -21,9 +25,17 @@ cloudwatchDashboardDisabled: {{values "cloudwatchDashboardDisabled"}}
|
|
|
21
25
|
datadogSecretId: '{{values "datadogSecretId"}}'
|
|
22
26
|
{{end}}
|
|
23
27
|
|
|
28
|
+
# Uncomment if the `tin` tier is acceptable for your SEEK Auth Sidecar logs
|
|
29
|
+
# The eeeoh log forwarder bypasses Amazon CloudWatch for cost savings
|
|
30
|
+
# logSink:
|
|
31
|
+
# forwarder: eeeoh
|
|
32
|
+
# splunkIndex: '{{values "logSink.splunkIndex"}}'
|
|
33
|
+
|
|
24
34
|
openTelemetry:
|
|
25
|
-
datadogEnvironmentName: '{{values "
|
|
35
|
+
datadogEnvironmentName: '{{values "env"}}'
|
|
26
36
|
enabled: {{values "openTelemetry.enabled"}}
|
|
37
|
+
useGantryServiceName: true
|
|
38
|
+
|
|
27
39
|
{{if .Values.pagerDutyEndpoint}}
|
|
28
40
|
pagerDutyEndpoint: '{{values "pagerDutyEndpoint"}}'
|
|
29
41
|
{{end}}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@koa/bodyparser": "^6.0.0",
|
|
17
|
-
"@koa/router": "^
|
|
17
|
+
"@koa/router": "^14.0.0",
|
|
18
18
|
"@opentelemetry/api": "^1.9.0",
|
|
19
19
|
"@opentelemetry/core": "^2.0.0",
|
|
20
20
|
"@opentelemetry/exporter-trace-otlp-grpc": "^0.203.0",
|
|
@@ -22,29 +22,28 @@
|
|
|
22
22
|
"@opentelemetry/instrumentation-http": "^0.203.0",
|
|
23
23
|
"@opentelemetry/propagator-b3": "^2.0.0",
|
|
24
24
|
"@opentelemetry/sdk-node": "^0.203.0",
|
|
25
|
-
"@seek/logger": "
|
|
26
|
-
"hot-shots": "^
|
|
27
|
-
"koa": "^
|
|
25
|
+
"@seek/logger": "11.0.0",
|
|
26
|
+
"hot-shots": "^11.0.0",
|
|
27
|
+
"koa": "^3.0.1",
|
|
28
28
|
"koa-compose": "^4.1.0",
|
|
29
|
-
"seek-datadog-custom-metrics": "^
|
|
30
|
-
"seek-koala": "^7.
|
|
29
|
+
"seek-datadog-custom-metrics": "^6.0.0",
|
|
30
|
+
"seek-koala": "^7.1.0",
|
|
31
31
|
"skuba-dive": "^2.0.0",
|
|
32
|
-
"zod": "^
|
|
32
|
+
"zod": "^4.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/chance": "^1.1.3",
|
|
36
36
|
"@types/co-body": "^6.1.3",
|
|
37
|
-
"@types/koa": "^
|
|
37
|
+
"@types/koa": "^3.0.0",
|
|
38
38
|
"@types/koa__router": "^12.0.0",
|
|
39
39
|
"@types/node": "^22.13.10",
|
|
40
40
|
"@types/supertest": "^6.0.0",
|
|
41
41
|
"chance": "^1.1.8",
|
|
42
|
-
"mime": "^4.0.1",
|
|
43
42
|
"pino-pretty": "^13.0.0",
|
|
44
43
|
"skuba": "*",
|
|
45
44
|
"supertest": "^7.0.0"
|
|
46
45
|
},
|
|
47
|
-
"packageManager": "pnpm@10.
|
|
46
|
+
"packageManager": "pnpm@10.14.0",
|
|
48
47
|
"engines": {
|
|
49
48
|
"node": ">=22"
|
|
50
49
|
}
|
|
@@ -3,8 +3,8 @@ import type { Middleware } from 'src/types/koa.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Signifies that the API is available to serve requests.
|
|
5
5
|
*
|
|
6
|
-
* The
|
|
7
|
-
* unhealthy and needs to be recycled.
|
|
6
|
+
* The workload hosting environment calls this endpoint to see if the container
|
|
7
|
+
* is unhealthy and needs to be recycled.
|
|
8
8
|
*/
|
|
9
9
|
export const healthCheckHandler: Middleware = (ctx) => {
|
|
10
10
|
ctx.state.skipRequestLogging = true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Env } from 'skuba-dive';
|
|
2
2
|
|
|
3
3
|
interface Config {
|
|
4
|
-
|
|
4
|
+
deployment: Deployment;
|
|
5
5
|
|
|
6
6
|
logLevel: string;
|
|
7
7
|
name: string;
|
|
@@ -11,17 +11,17 @@ interface Config {
|
|
|
11
11
|
port: number | null;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
type
|
|
14
|
+
type Deployment = (typeof deployments)[number];
|
|
15
15
|
|
|
16
16
|
const dev = '<%- devGantryEnvironmentName %>';
|
|
17
17
|
const prod = '<%- prodGantryEnvironmentName %>';
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const deployments = ['local', 'test', dev, prod] as const;
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const deployment = Env.oneOf(deployments)('DEPLOYMENT');
|
|
22
22
|
|
|
23
23
|
/* istanbul ignore next: config verification makes more sense in a smoke test */
|
|
24
|
-
const configs: Record<
|
|
24
|
+
const configs: Record<Deployment, () => Omit<Config, 'deployment'>> = {
|
|
25
25
|
local: () => ({
|
|
26
26
|
logLevel: 'debug',
|
|
27
27
|
name: '<%- serviceName %>',
|
|
@@ -62,6 +62,6 @@ const configs: Record<Environment, () => Omit<Config, 'environment'>> = {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export const config: Config = {
|
|
65
|
-
...configs[
|
|
66
|
-
|
|
65
|
+
...configs[deployment](),
|
|
66
|
+
deployment,
|
|
67
67
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createDestination, createLogger } from '@seek/logger';
|
|
2
2
|
import { RequestLogging } from 'seek-koala';
|
|
3
3
|
|
|
4
4
|
import { config } from 'src/config.js';
|
|
@@ -9,26 +9,30 @@ const { createContextMiddleware, mixin } =
|
|
|
9
9
|
export const contextMiddleware = createContextMiddleware();
|
|
10
10
|
|
|
11
11
|
const { destination, stdoutMock } = createDestination({
|
|
12
|
-
mock: config.
|
|
12
|
+
mock: config.deployment === 'test',
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
export { stdoutMock };
|
|
16
16
|
|
|
17
17
|
export const logger = createLogger(
|
|
18
18
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
eeeoh: {
|
|
20
|
+
/**
|
|
21
|
+
* TODO: choose an appropriate Datadog log tier.
|
|
22
|
+
*
|
|
23
|
+
* https://github.com/seek-oss/logger/blob/master/docs/eeeoh.md#datadog-log-tiers
|
|
24
|
+
*/
|
|
25
|
+
datadog: 'tin',
|
|
26
|
+
team: '<%- teamName %>',
|
|
27
|
+
use: 'environment',
|
|
22
28
|
},
|
|
23
29
|
|
|
24
30
|
mixin,
|
|
25
31
|
|
|
26
32
|
level: config.logLevel,
|
|
27
33
|
|
|
28
|
-
name: config.name,
|
|
29
|
-
|
|
30
34
|
transport:
|
|
31
|
-
config.
|
|
35
|
+
config.deployment === 'local' ? { target: 'pino-pretty' } : undefined,
|
|
32
36
|
},
|
|
33
37
|
destination,
|
|
34
38
|
);
|
|
@@ -7,5 +7,5 @@ import { logger } from './logging.js';
|
|
|
7
7
|
|
|
8
8
|
/* istanbul ignore next: StatsD client is not our responsibility */
|
|
9
9
|
export const metricsClient = createStatsDClient(StatsD, config, (err) =>
|
|
10
|
-
logger.error(
|
|
10
|
+
logger.error(err, 'StatsD error'),
|
|
11
11
|
);
|
|
@@ -32,7 +32,6 @@ describe('createApp', () => {
|
|
|
32
32
|
|
|
33
33
|
expect(stdoutMock.calls).toHaveLength(0);
|
|
34
34
|
|
|
35
|
-
metricsClient.expectTagSubset(['env:test', 'version:test']);
|
|
36
35
|
metricsClient.expectTagSubset([
|
|
37
36
|
'http_method:get',
|
|
38
37
|
'http_status:200',
|
|
@@ -133,7 +132,7 @@ describe('createApp', () => {
|
|
|
133
132
|
|
|
134
133
|
expect(stdoutMock.calls).toMatchObject([
|
|
135
134
|
{
|
|
136
|
-
|
|
135
|
+
error: {
|
|
137
136
|
statusCode: 400,
|
|
138
137
|
type: 'BadRequestError',
|
|
139
138
|
},
|
|
@@ -167,7 +166,7 @@ describe('createApp', () => {
|
|
|
167
166
|
|
|
168
167
|
expect(stdoutMock.calls).toMatchObject([
|
|
169
168
|
{
|
|
170
|
-
|
|
169
|
+
error: {
|
|
171
170
|
statusCode: 500,
|
|
172
171
|
type: 'InternalServerError',
|
|
173
172
|
},
|
|
@@ -203,7 +202,7 @@ describe('createApp', () => {
|
|
|
203
202
|
|
|
204
203
|
expect(stdoutMock.calls).toMatchObject([
|
|
205
204
|
{
|
|
206
|
-
|
|
205
|
+
error: {
|
|
207
206
|
message: err.message,
|
|
208
207
|
type: 'Error',
|
|
209
208
|
},
|
|
@@ -237,7 +236,7 @@ describe('createApp', () => {
|
|
|
237
236
|
|
|
238
237
|
expect(stdoutMock.calls).toMatchObject([
|
|
239
238
|
{
|
|
240
|
-
|
|
239
|
+
error: null,
|
|
241
240
|
level: 50,
|
|
242
241
|
method: 'GET',
|
|
243
242
|
msg: 'Server error',
|
|
@@ -256,10 +255,10 @@ describe('createApp', () => {
|
|
|
256
255
|
});
|
|
257
256
|
|
|
258
257
|
it('handles string error', async () => {
|
|
259
|
-
const
|
|
258
|
+
const error = chance.sentence();
|
|
260
259
|
|
|
261
260
|
middleware.mockImplementation(() => {
|
|
262
|
-
throw
|
|
261
|
+
throw error;
|
|
263
262
|
});
|
|
264
263
|
|
|
265
264
|
await agent
|
|
@@ -270,7 +269,7 @@ describe('createApp', () => {
|
|
|
270
269
|
|
|
271
270
|
expect(stdoutMock.calls).toMatchObject([
|
|
272
271
|
{
|
|
273
|
-
|
|
272
|
+
error,
|
|
274
273
|
level: 50,
|
|
275
274
|
method: 'GET',
|
|
276
275
|
msg: 'Server error',
|
|
@@ -30,10 +30,7 @@ const requestLogging = RequestLogging.createMiddleware((ctx, fields, err) => {
|
|
|
30
30
|
: logger.error(fields, 'Server error');
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
const version = VersionMiddleware.create(
|
|
34
|
-
name: config.name,
|
|
35
|
-
version: config.version,
|
|
36
|
-
});
|
|
33
|
+
const version = VersionMiddleware.create(config);
|
|
37
34
|
|
|
38
35
|
export const createApp = <State, Context>(
|
|
39
36
|
...middleware: Array<Koa.Middleware<State, Context>>
|
|
@@ -22,3 +22,9 @@ const listener = app.listen(config.port, () => {
|
|
|
22
22
|
// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout
|
|
23
23
|
// AWS recommends setting an application timeout larger than the load balancer
|
|
24
24
|
listener.keepAliveTimeout = 31000;
|
|
25
|
+
|
|
26
|
+
// Report unhandled rejections instead of crashing the process
|
|
27
|
+
// Make sure to monitor these reports and alert as appropriate
|
|
28
|
+
process.on('unhandledRejection', (err) =>
|
|
29
|
+
logger.error(err, 'Unhandled promise rejection'),
|
|
30
|
+
);
|
|
@@ -81,7 +81,9 @@ steps:
|
|
|
81
81
|
agents:
|
|
82
82
|
queue: <%- devBuildkiteQueueName %>
|
|
83
83
|
env:
|
|
84
|
-
|
|
84
|
+
DD_DEPLOYMENT_ENVIRONMENT: development
|
|
85
|
+
DD_DEPLOYMENT_SERVICE: <%- serviceName %>
|
|
86
|
+
DEPLOYMENT: dev
|
|
85
87
|
GET_NPM_TOKEN: please
|
|
86
88
|
label: 🤞 Deploy Dev
|
|
87
89
|
concurrency_group: '<%- repoName %>/deploy/dev'
|
|
@@ -89,7 +91,9 @@ steps:
|
|
|
89
91
|
|
|
90
92
|
- <<: *deploy
|
|
91
93
|
env:
|
|
92
|
-
|
|
94
|
+
DD_DEPLOYMENT_ENVIRONMENT: production
|
|
95
|
+
DD_DEPLOYMENT_SERVICE: <%- serviceName %>
|
|
96
|
+
DEPLOYMENT: prod
|
|
93
97
|
GET_NPM_TOKEN: please
|
|
94
98
|
label: 🚀 Deploy Prod
|
|
95
99
|
branches: ${BUILDKITE_PIPELINE_DEFAULT_BRANCH}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
DEPLOYMENT=local
|
|
@@ -54,7 +54,7 @@ pnpm test
|
|
|
54
54
|
awsauth
|
|
55
55
|
|
|
56
56
|
# Run smoke test against deployed application
|
|
57
|
-
|
|
57
|
+
DEPLOYMENT=dev pnpm smoke
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
### Lint
|
|
@@ -88,8 +88,8 @@ curl --data '[{}, {"awsRequestId": "local"}]' --include localhost:<%- port %>
|
|
|
88
88
|
|
|
89
89
|
This project is deployed through a [Buildkite pipeline](.buildkite/pipeline.yml).
|
|
90
90
|
|
|
91
|
-
- Commits to a feature branch can be deployed to the
|
|
92
|
-
- Commits to the default branch are automatically deployed to the
|
|
91
|
+
- Commits to a feature branch can be deployed to the development environment by unblocking a step in the Buildkite UI
|
|
92
|
+
- Commits to the default branch are automatically deployed to the development and production environments in sequence
|
|
93
93
|
|
|
94
94
|
To deploy locally:
|
|
95
95
|
|
|
@@ -97,7 +97,7 @@ To deploy locally:
|
|
|
97
97
|
# Authenticate to dev account
|
|
98
98
|
awsauth
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
DEPLOYMENT=dev pnpm run deploy
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
A hotswap deploy enables faster deployment but come with caveats such as requiring a Lambda to be rebuilt with every build.
|
|
@@ -108,19 +108,19 @@ To deploy a [hotswap]:
|
|
|
108
108
|
# Authenticate to dev account
|
|
109
109
|
awsauth
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
DEPLOYMENT=dev pnpm run deploy:hotswap
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
To rapidly roll back a change,
|
|
115
115
|
retry an individual deployment step from the previous build in Buildkite.
|
|
116
|
-
Note that this will introduce drift between the head of the default Git branch and the live
|
|
116
|
+
Note that this will introduce drift between the head of the default Git branch and the live deployment;
|
|
117
117
|
use with caution and always follow up with a proper revert or fix in Git history.
|
|
118
118
|
|
|
119
119
|
## Support
|
|
120
120
|
|
|
121
121
|
### Dev
|
|
122
122
|
|
|
123
|
-
TODO: add support links for the dev
|
|
123
|
+
TODO: add support links for the dev deployment.
|
|
124
124
|
|
|
125
125
|
<!--
|
|
126
126
|
- CloudWatch dashboard
|
|
@@ -130,7 +130,7 @@ TODO: add support links for the dev environment.
|
|
|
130
130
|
|
|
131
131
|
### Prod
|
|
132
132
|
|
|
133
|
-
TODO: add support links for the prod
|
|
133
|
+
TODO: add support links for the prod deployment.
|
|
134
134
|
|
|
135
135
|
<!--
|
|
136
136
|
- CloudWatch dashboard
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
4
4
|
{
|
|
@@ -180,28 +180,29 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
180
180
|
"Ref": "datadogapikeysecret046FEF06",
|
|
181
181
|
},
|
|
182
182
|
"DD_CAPTURE_LAMBDA_PAYLOAD": "false",
|
|
183
|
+
"DD_ENV": "development",
|
|
183
184
|
"DD_FLUSH_TO_LOG": "false",
|
|
184
185
|
"DD_LAMBDA_HANDLER": "index.handler",
|
|
185
186
|
"DD_LOGS_INJECTION": "false",
|
|
186
187
|
"DD_MERGE_XRAY_TRACES": "false",
|
|
187
188
|
"DD_SERVERLESS_APPSEC_ENABLED": "false",
|
|
188
189
|
"DD_SERVERLESS_LOGS_ENABLED": "false",
|
|
190
|
+
"DD_SERVICE": "serviceName",
|
|
189
191
|
"DD_SITE": "datadoghq.com",
|
|
190
192
|
"DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING": "$.*",
|
|
191
193
|
"DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING": "$.*",
|
|
192
194
|
"DD_TRACE_ENABLED": "true",
|
|
195
|
+
"DD_VERSION": "local",
|
|
196
|
+
"DEPLOYMENT": "dev",
|
|
193
197
|
"DESTINATION_SNS_TOPIC_ARN": {
|
|
194
198
|
"Ref": "destinationtopicDCE2E0B8",
|
|
195
199
|
},
|
|
196
|
-
"ENVIRONMENT": "dev",
|
|
197
200
|
"NODE_ENV": "production",
|
|
198
201
|
"NODE_OPTIONS": "--enable-source-maps",
|
|
199
|
-
"SERVICE": "serviceName",
|
|
200
|
-
"VERSION": "local",
|
|
201
202
|
},
|
|
202
203
|
},
|
|
203
204
|
"FunctionName": "serviceName",
|
|
204
|
-
"Handler": "node_modules/datadog-lambda-js/
|
|
205
|
+
"Handler": "/opt/nodejs/node_modules/datadog-lambda-js/handler.handler",
|
|
205
206
|
"KmsKeyArn": {
|
|
206
207
|
"Fn::GetAtt": [
|
|
207
208
|
"kmskey49FBC3B3",
|
|
@@ -209,6 +210,18 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
209
210
|
],
|
|
210
211
|
},
|
|
211
212
|
"Layers": [
|
|
213
|
+
{
|
|
214
|
+
"Fn::Join": [
|
|
215
|
+
"",
|
|
216
|
+
[
|
|
217
|
+
"arn:aws:lambda:",
|
|
218
|
+
{
|
|
219
|
+
"Ref": "AWS::Region",
|
|
220
|
+
},
|
|
221
|
+
":464622532012:layer:Datadog-Node22-x:x",
|
|
222
|
+
],
|
|
223
|
+
],
|
|
224
|
+
},
|
|
212
225
|
{
|
|
213
226
|
"Fn::Join": [
|
|
214
227
|
"",
|
|
@@ -222,7 +235,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
222
235
|
],
|
|
223
236
|
},
|
|
224
237
|
],
|
|
225
|
-
"ReservedConcurrentExecutions":
|
|
238
|
+
"ReservedConcurrentExecutions": 3,
|
|
226
239
|
"Role": {
|
|
227
240
|
"Fn::GetAtt": [
|
|
228
241
|
"workerServiceRole2130CC7F",
|
|
@@ -332,6 +345,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
332
345
|
},
|
|
333
346
|
"workerAliasLiveSqsEventSourceappStackworkerqueue8281B9F443B0CF93": {
|
|
334
347
|
"Properties": {
|
|
348
|
+
"BatchSize": 10,
|
|
335
349
|
"EventSourceArn": {
|
|
336
350
|
"Fn::GetAtt": [
|
|
337
351
|
"workerqueueA05CE5C6",
|
|
@@ -359,6 +373,12 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
359
373
|
],
|
|
360
374
|
],
|
|
361
375
|
},
|
|
376
|
+
"FunctionResponseTypes": [
|
|
377
|
+
"ReportBatchItemFailures",
|
|
378
|
+
],
|
|
379
|
+
"ScalingConfig": {
|
|
380
|
+
"MaximumConcurrency": 2,
|
|
381
|
+
},
|
|
362
382
|
"Tags": [
|
|
363
383
|
{
|
|
364
384
|
"Key": "aws-codedeploy-hooks",
|
|
@@ -913,28 +933,29 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
913
933
|
"Ref": "datadogapikeysecret046FEF06",
|
|
914
934
|
},
|
|
915
935
|
"DD_CAPTURE_LAMBDA_PAYLOAD": "false",
|
|
936
|
+
"DD_ENV": "production",
|
|
916
937
|
"DD_FLUSH_TO_LOG": "false",
|
|
917
938
|
"DD_LAMBDA_HANDLER": "index.handler",
|
|
918
939
|
"DD_LOGS_INJECTION": "false",
|
|
919
940
|
"DD_MERGE_XRAY_TRACES": "false",
|
|
920
941
|
"DD_SERVERLESS_APPSEC_ENABLED": "false",
|
|
921
942
|
"DD_SERVERLESS_LOGS_ENABLED": "false",
|
|
943
|
+
"DD_SERVICE": "serviceName",
|
|
922
944
|
"DD_SITE": "datadoghq.com",
|
|
923
945
|
"DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING": "$.*",
|
|
924
946
|
"DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING": "$.*",
|
|
925
947
|
"DD_TRACE_ENABLED": "true",
|
|
948
|
+
"DD_VERSION": "local",
|
|
949
|
+
"DEPLOYMENT": "prod",
|
|
926
950
|
"DESTINATION_SNS_TOPIC_ARN": {
|
|
927
951
|
"Ref": "destinationtopicDCE2E0B8",
|
|
928
952
|
},
|
|
929
|
-
"ENVIRONMENT": "prod",
|
|
930
953
|
"NODE_ENV": "production",
|
|
931
954
|
"NODE_OPTIONS": "--enable-source-maps",
|
|
932
|
-
"SERVICE": "serviceName",
|
|
933
|
-
"VERSION": "local",
|
|
934
955
|
},
|
|
935
956
|
},
|
|
936
957
|
"FunctionName": "serviceName",
|
|
937
|
-
"Handler": "node_modules/datadog-lambda-js/
|
|
958
|
+
"Handler": "/opt/nodejs/node_modules/datadog-lambda-js/handler.handler",
|
|
938
959
|
"KmsKeyArn": {
|
|
939
960
|
"Fn::GetAtt": [
|
|
940
961
|
"kmskey49FBC3B3",
|
|
@@ -942,6 +963,18 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
942
963
|
],
|
|
943
964
|
},
|
|
944
965
|
"Layers": [
|
|
966
|
+
{
|
|
967
|
+
"Fn::Join": [
|
|
968
|
+
"",
|
|
969
|
+
[
|
|
970
|
+
"arn:aws:lambda:",
|
|
971
|
+
{
|
|
972
|
+
"Ref": "AWS::Region",
|
|
973
|
+
},
|
|
974
|
+
":464622532012:layer:Datadog-Node22-x:x",
|
|
975
|
+
],
|
|
976
|
+
],
|
|
977
|
+
},
|
|
945
978
|
{
|
|
946
979
|
"Fn::Join": [
|
|
947
980
|
"",
|
|
@@ -1065,6 +1098,7 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
1065
1098
|
},
|
|
1066
1099
|
"workerAliasLiveSqsEventSourceappStackworkerqueue8281B9F443B0CF93": {
|
|
1067
1100
|
"Properties": {
|
|
1101
|
+
"BatchSize": 10,
|
|
1068
1102
|
"EventSourceArn": {
|
|
1069
1103
|
"Fn::GetAtt": [
|
|
1070
1104
|
"workerqueueA05CE5C6",
|
|
@@ -1092,6 +1126,12 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
1092
1126
|
],
|
|
1093
1127
|
],
|
|
1094
1128
|
},
|
|
1129
|
+
"FunctionResponseTypes": [
|
|
1130
|
+
"ReportBatchItemFailures",
|
|
1131
|
+
],
|
|
1132
|
+
"ScalingConfig": {
|
|
1133
|
+
"MaximumConcurrency": 19,
|
|
1134
|
+
},
|
|
1095
1135
|
"Tags": [
|
|
1096
1136
|
{
|
|
1097
1137
|
"Key": "aws-codedeploy-hooks",
|
|
@@ -15,11 +15,11 @@ jest.useFakeTimers({
|
|
|
15
15
|
now: new Date(currentDate),
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const originalDeployment = process.env.DEPLOYMENT;
|
|
19
19
|
const originalVersion = process.env.VERSION;
|
|
20
20
|
|
|
21
21
|
afterAll(() => {
|
|
22
|
-
process.env.
|
|
22
|
+
process.env.DEPLOYMENT = originalDeployment;
|
|
23
23
|
process.env.VERSION = originalVersion;
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -29,8 +29,8 @@ afterEach(() => {
|
|
|
29
29
|
|
|
30
30
|
it.each(['dev', 'prod'])(
|
|
31
31
|
'returns expected CloudFormation stack for %s',
|
|
32
|
-
async (
|
|
33
|
-
process.env.
|
|
32
|
+
async (deployment) => {
|
|
33
|
+
process.env.DEPLOYMENT = deployment;
|
|
34
34
|
process.env.VERSION = 'local';
|
|
35
35
|
|
|
36
36
|
const { AppStack } = await import('./appStack.js');
|
|
@@ -69,10 +69,7 @@ it.each(['dev', 'prod'])(
|
|
|
69
69
|
/"DD_TAGS":"git.commit.sha:([0-9a-f]+),git.repository_url:([^\"]+)",/g,
|
|
70
70
|
'',
|
|
71
71
|
)
|
|
72
|
-
.replaceAll(
|
|
73
|
-
/(layer:Datadog-Extension-.+?:)\d+/g,
|
|
74
|
-
(_, layer) => `${layer}x`,
|
|
75
|
-
);
|
|
72
|
+
.replaceAll(/(layer:Datadog-[^-]+-.+?:)\d+/g, (_, layer) => `${layer}x`);
|
|
76
73
|
expect(JSON.parse(json)).toMatchSnapshot();
|
|
77
74
|
},
|
|
78
75
|
);
|