skuba 9.0.1-upgrade-cdk-template-20241002233314 → 9.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.
- package/lib/cli/lint/autofix.js +15 -0
- package/lib/cli/lint/autofix.js.map +2 -2
- package/package.json +1 -1
- package/template/express-rest-api/package.json +1 -1
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/package.json +1 -1
- package/template/lambda-sqs-worker/package.json +1 -1
- package/template/lambda-sqs-worker/serverless.yml +1 -1
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +134 -102
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +2 -13
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +6 -52
- package/template/lambda-sqs-worker-cdk/infra/config.ts +0 -3
- package/template/lambda-sqs-worker-cdk/package.json +2 -9
- package/template/lambda-sqs-worker-cdk/src/app.ts +21 -43
- package/template/lambda-sqs-worker-cdk/src/config.ts +0 -15
- package/template/lambda-sqs-worker-cdk/.env +0 -1
- package/template/lambda-sqs-worker-cdk/README.md +0 -145
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +0 -116
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +0 -61
- package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +0 -43
- package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +0 -27
- package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +0 -14
- package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +0 -84
- package/template/lambda-sqs-worker-cdk/src/framework/validation.ts +0 -10
- package/template/lambda-sqs-worker-cdk/src/mapping/jobScorer.ts +0 -22
- package/template/lambda-sqs-worker-cdk/src/services/aws.ts +0 -5
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +0 -44
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.ts +0 -59
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +0 -40
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.ts +0 -33
- package/template/lambda-sqs-worker-cdk/src/testing/handler.ts +0 -13
- package/template/lambda-sqs-worker-cdk/src/testing/logging.ts +0 -19
- package/template/lambda-sqs-worker-cdk/src/testing/services.ts +0 -28
- package/template/lambda-sqs-worker-cdk/src/testing/types.ts +0 -33
- package/template/lambda-sqs-worker-cdk/src/types/jobScorer.ts +0 -15
- package/template/lambda-sqs-worker-cdk/src/types/pipelineEvents.ts +0 -21
package/lib/cli/lint/autofix.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(autofix_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(autofix_exports);
|
|
36
36
|
var import_util = require("util");
|
|
37
37
|
var import_simple_git = __toESM(require("simple-git"));
|
|
38
|
+
var Buildkite = __toESM(require("../../api/buildkite"));
|
|
38
39
|
var Git = __toESM(require("../../api/git"));
|
|
39
40
|
var GitHub = __toESM(require("../../api/github"));
|
|
40
41
|
var import_env = require("../../utils/env");
|
|
@@ -45,6 +46,7 @@ var import_eslint = require("../adapter/eslint");
|
|
|
45
46
|
var import_prettier = require("../adapter/prettier");
|
|
46
47
|
var import_project = require("../configure/analysis/project");
|
|
47
48
|
var import_internal = require("./internal");
|
|
49
|
+
const RENOVATE_DEFAULT_PREFIX = "renovate";
|
|
48
50
|
const AUTOFIX_COMMIT_MESSAGE = "Run `skuba format`";
|
|
49
51
|
const AUTOFIX_IGNORE_FILES_BASE = [
|
|
50
52
|
{
|
|
@@ -76,6 +78,19 @@ const shouldPush = async ({
|
|
|
76
78
|
if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {
|
|
77
79
|
return false;
|
|
78
80
|
}
|
|
81
|
+
if (currentBranch?.startsWith(RENOVATE_DEFAULT_PREFIX)) {
|
|
82
|
+
try {
|
|
83
|
+
await GitHub.getPullRequestNumber();
|
|
84
|
+
} catch {
|
|
85
|
+
const warning = "An autofix is available, but it was not pushed because an open pull request for this Renovate branch could not be found. If a pull request has since been created, retry the lint step to push the fix.";
|
|
86
|
+
import_logging.log.warn(warning);
|
|
87
|
+
try {
|
|
88
|
+
await Buildkite.annotate(Buildkite.md.terminal(warning));
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
79
94
|
let headCommitMessage;
|
|
80
95
|
try {
|
|
81
96
|
headCommitMessage = await Git.getHeadCommitMessage({ dir });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/autofix.ts"],
|
|
4
|
-
"sourcesContent": ["import { inspect } from 'util';\n\nimport simpleGit from 'simple-git';\n\nimport * as Git from '../../api/git';\nimport * as GitHub from '../../api/github';\nimport { isCiEnv } from '../../utils/env';\nimport { createLogger, log } from '../../utils/logging';\nimport { hasNpmrcSecret } from '../../utils/npmrc';\nimport { throwOnTimeout } from '../../utils/wait';\nimport { runESLint } from '../adapter/eslint';\nimport { runPrettier } from '../adapter/prettier';\nimport { createDestinationFileReader } from '../configure/analysis/project';\n\nimport { internalLint } from './internal';\nimport type { Input } from './types';\n\nconst AUTOFIX_COMMIT_MESSAGE = 'Run `skuba format`';\n\nexport const AUTOFIX_IGNORE_FILES_BASE: Git.ChangedFile[] = [\n {\n path: 'Dockerfile-incunabulum',\n state: 'added',\n },\n];\n\nexport const AUTOFIX_IGNORE_FILES_NPMRC: Git.ChangedFile[] = [\n {\n path: '.npmrc',\n state: 'added',\n },\n {\n path: '.npmrc',\n state: 'modified',\n },\n];\n\nconst shouldPush = async ({\n currentBranch,\n dir,\n}: {\n currentBranch?: string;\n dir: string;\n}) => {\n if (!isCiEnv()) {\n // We're not running in a CI environment so we don't need to push autofixes.\n // Ideally we'd drive this off of repository write permissions, but that is\n // non-trivial to infer without attempting an actual write.\n return false;\n }\n\n const isDefaultBuildkiteBranch =\n currentBranch &&\n [process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH, 'master', 'main'].includes(\n currentBranch,\n );\n\n const isProtectedGitHubBranch = process.env.GITHUB_REF_PROTECTED === 'true';\n\n if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {\n // The current branch is a protected branch.\n // We respect GitHub Flow; avoid pushing directly to the default branch.\n return false;\n }\n\n let headCommitMessage;\n try {\n headCommitMessage = await Git.getHeadCommitMessage({ dir });\n } catch {}\n\n if (headCommitMessage?.startsWith(AUTOFIX_COMMIT_MESSAGE)) {\n // Short circuit when the head commit appears to be one of our autofixes.\n // Repeating the same operation is unlikely to correct outstanding issues.\n return false;\n }\n\n // Allow the push attempt to go ahead if our guards have been cleared.\n return true;\n};\n\nconst getIgnores = async (dir: string): Promise<Git.ChangedFile[]> => {\n const contents = await createDestinationFileReader(dir)('.npmrc');\n\n // If an .npmrc has secrets, we need to ignore it\n if (hasNpmrcSecret(contents ?? '')) {\n return [...AUTOFIX_IGNORE_FILES_BASE, ...AUTOFIX_IGNORE_FILES_NPMRC];\n }\n\n return AUTOFIX_IGNORE_FILES_BASE;\n};\n\ninterface AutofixParameters {\n debug: Input['debug'];\n\n eslint: boolean;\n prettier: boolean;\n internal: boolean;\n\n eslintConfigFile?: string;\n}\n\nexport const autofix = async (params: AutofixParameters): Promise<void> => {\n const dir = process.cwd();\n\n if (!params.eslint && !params.prettier && !params.internal) {\n return;\n }\n\n let currentBranch;\n try {\n currentBranch = await Git.currentBranch({ dir });\n } catch {}\n\n if (!(await shouldPush({ currentBranch, dir }))) {\n return;\n }\n\n try {\n log.newline();\n\n log.warn(\n `Attempting to autofix issues (${[\n params.eslint ? 'ESLint' : undefined,\n params.internal ? 'skuba' : undefined,\n 'Prettier', // Prettier is always run\n ]\n .filter((s) => s !== undefined)\n .join(', ')})...`,\n );\n\n const logger = createLogger(params.debug);\n\n if (params.internal) {\n await internalLint('format');\n }\n\n if (params.eslint) {\n await runESLint('format', logger, params.eslintConfigFile);\n }\n\n // Unconditionally re-run Prettier; reaching here means we have pre-existing\n // format violations or may have created new ones through ESLint/internal fixes.\n await runPrettier('format', logger);\n\n if (process.env.GITHUB_ACTIONS) {\n // GitHub runners have Git installed locally\n const ref = await Git.commitAllChanges({\n dir,\n message: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n });\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n await throwOnTimeout(simpleGit().push(), { s: 30 });\n log.warn(`Pushed fix commit ${ref}.`);\n return;\n }\n\n // Other CI Environments, use GitHub API\n if (!currentBranch) {\n log.warn('Could not determine the current branch.');\n log.warn(\n 'Please propagate BUILDKITE_BRANCH, GITHUB_HEAD_REF, GITHUB_REF_NAME, or the .git directory to your container.',\n );\n return;\n }\n\n const ref = await throwOnTimeout(\n GitHub.uploadAllFileChanges({\n branch: currentBranch,\n dir,\n messageHeadline: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n }),\n { s: 30 },\n );\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n log.warn(`Pushed fix commit ${ref}.`);\n } catch (err) {\n log.warn(log.bold('Failed to push fix commit.'));\n log.warn(\n log.bold(\n 'Does your CI environment have write access to your Git repository?',\n ),\n );\n log.subtle(inspect(err));\n }\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,wBAAsB;AAEtB,UAAqB;AACrB,aAAwB;AACxB,iBAAwB;AACxB,qBAAkC;AAClC,mBAA+B;AAC/B,kBAA+B;AAC/B,oBAA0B;AAC1B,sBAA4B;AAC5B,qBAA4C;AAE5C,sBAA6B;AAG7B,MAAM,yBAAyB;AAExB,MAAM,4BAA+C;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;AAEO,MAAM,6BAAgD;AAAA,EAC3D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,E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AAAA,EACzB;AACF;",
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport simpleGit from 'simple-git';\n\nimport * as Buildkite from '../../api/buildkite';\nimport * as Git from '../../api/git';\nimport * as GitHub from '../../api/github';\nimport { isCiEnv } from '../../utils/env';\nimport { createLogger, log } from '../../utils/logging';\nimport { hasNpmrcSecret } from '../../utils/npmrc';\nimport { throwOnTimeout } from '../../utils/wait';\nimport { runESLint } from '../adapter/eslint';\nimport { runPrettier } from '../adapter/prettier';\nimport { createDestinationFileReader } from '../configure/analysis/project';\n\nimport { internalLint } from './internal';\nimport type { Input } from './types';\n\nconst RENOVATE_DEFAULT_PREFIX = 'renovate';\n\nconst AUTOFIX_COMMIT_MESSAGE = 'Run `skuba format`';\n\nexport const AUTOFIX_IGNORE_FILES_BASE: Git.ChangedFile[] = [\n {\n path: 'Dockerfile-incunabulum',\n state: 'added',\n },\n];\n\nexport const AUTOFIX_IGNORE_FILES_NPMRC: Git.ChangedFile[] = [\n {\n path: '.npmrc',\n state: 'added',\n },\n {\n path: '.npmrc',\n state: 'modified',\n },\n];\n\nconst shouldPush = async ({\n currentBranch,\n dir,\n}: {\n currentBranch?: string;\n dir: string;\n}) => {\n if (!isCiEnv()) {\n // We're not running in a CI environment so we don't need to push autofixes.\n // Ideally we'd drive this off of repository write permissions, but that is\n // non-trivial to infer without attempting an actual write.\n return false;\n }\n\n const isDefaultBuildkiteBranch =\n currentBranch &&\n [process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH, 'master', 'main'].includes(\n currentBranch,\n );\n\n const isProtectedGitHubBranch = process.env.GITHUB_REF_PROTECTED === 'true';\n\n if (isDefaultBuildkiteBranch || isProtectedGitHubBranch) {\n // The current branch is a protected branch.\n // We respect GitHub Flow; avoid pushing directly to the default branch.\n return false;\n }\n\n if (currentBranch?.startsWith(RENOVATE_DEFAULT_PREFIX)) {\n try {\n await GitHub.getPullRequestNumber();\n } catch {\n const warning =\n 'An autofix is available, but it was not pushed because an open pull request for this Renovate branch could not be found. If a pull request has since been created, retry the lint step to push the fix.';\n log.warn(warning);\n try {\n await Buildkite.annotate(Buildkite.md.terminal(warning));\n } catch {}\n\n return false;\n }\n }\n\n let headCommitMessage;\n try {\n headCommitMessage = await Git.getHeadCommitMessage({ dir });\n } catch {}\n\n if (headCommitMessage?.startsWith(AUTOFIX_COMMIT_MESSAGE)) {\n // Short circuit when the head commit appears to be one of our autofixes.\n // Repeating the same operation is unlikely to correct outstanding issues.\n return false;\n }\n\n // Allow the push attempt to go ahead if our guards have been cleared.\n return true;\n};\n\nconst getIgnores = async (dir: string): Promise<Git.ChangedFile[]> => {\n const contents = await createDestinationFileReader(dir)('.npmrc');\n\n // If an .npmrc has secrets, we need to ignore it\n if (hasNpmrcSecret(contents ?? '')) {\n return [...AUTOFIX_IGNORE_FILES_BASE, ...AUTOFIX_IGNORE_FILES_NPMRC];\n }\n\n return AUTOFIX_IGNORE_FILES_BASE;\n};\n\ninterface AutofixParameters {\n debug: Input['debug'];\n\n eslint: boolean;\n prettier: boolean;\n internal: boolean;\n\n eslintConfigFile?: string;\n}\n\nexport const autofix = async (params: AutofixParameters): Promise<void> => {\n const dir = process.cwd();\n\n if (!params.eslint && !params.prettier && !params.internal) {\n return;\n }\n\n let currentBranch;\n try {\n currentBranch = await Git.currentBranch({ dir });\n } catch {}\n\n if (!(await shouldPush({ currentBranch, dir }))) {\n return;\n }\n\n try {\n log.newline();\n\n log.warn(\n `Attempting to autofix issues (${[\n params.eslint ? 'ESLint' : undefined,\n params.internal ? 'skuba' : undefined,\n 'Prettier', // Prettier is always run\n ]\n .filter((s) => s !== undefined)\n .join(', ')})...`,\n );\n\n const logger = createLogger(params.debug);\n\n if (params.internal) {\n await internalLint('format');\n }\n\n if (params.eslint) {\n await runESLint('format', logger, params.eslintConfigFile);\n }\n\n // Unconditionally re-run Prettier; reaching here means we have pre-existing\n // format violations or may have created new ones through ESLint/internal fixes.\n await runPrettier('format', logger);\n\n if (process.env.GITHUB_ACTIONS) {\n // GitHub runners have Git installed locally\n const ref = await Git.commitAllChanges({\n dir,\n message: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n });\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n await throwOnTimeout(simpleGit().push(), { s: 30 });\n log.warn(`Pushed fix commit ${ref}.`);\n return;\n }\n\n // Other CI Environments, use GitHub API\n if (!currentBranch) {\n log.warn('Could not determine the current branch.');\n log.warn(\n 'Please propagate BUILDKITE_BRANCH, GITHUB_HEAD_REF, GITHUB_REF_NAME, or the .git directory to your container.',\n );\n return;\n }\n\n const ref = await throwOnTimeout(\n GitHub.uploadAllFileChanges({\n branch: currentBranch,\n dir,\n messageHeadline: AUTOFIX_COMMIT_MESSAGE,\n\n ignore: await getIgnores(dir),\n }),\n { s: 30 },\n );\n\n if (!ref) {\n return log.warn('No autofixes detected.');\n }\n\n log.warn(`Pushed fix commit ${ref}.`);\n } catch (err) {\n log.warn(log.bold('Failed to push fix commit.'));\n log.warn(\n log.bold(\n 'Does your CI environment have write access to your Git repository?',\n ),\n );\n log.subtle(inspect(err));\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,wBAAsB;AAEtB,gBAA2B;AAC3B,UAAqB;AACrB,aAAwB;AACxB,iBAAwB;AACxB,qBAAkC;AAClC,mBAA+B;AAC/B,kBAA+B;AAC/B,oBAA0B;AAC1B,sBAA4B;AAC5B,qBAA4C;AAE5C,sBAA6B;AAG7B,MAAM,0BAA0B;AAEhC,MAAM,yBAAyB;AAExB,MAAM,4BAA+C;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;AAEO,MAAM,6BAAgD;AAAA,EAC3D;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN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BAAwB;AAAA,IAC1C;AAEA,uBAAI,KAAK,qBAAqB,GAAG,GAAG;AAAA,EACtC,SAAS,KAAK;AACZ,uBAAI,KAAK,mBAAI,KAAK,4BAA4B,CAAC;AAC/C,uBAAI;AAAA,MACF,mBAAI;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AAAA,EACzB;AACF;",
|
|
6
6
|
"names": ["ref", "simpleGit"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -173,7 +173,7 @@ resources:
|
|
|
173
173
|
# Properties:
|
|
174
174
|
# Endpoint: !GetAtt MessageQueue.Arn
|
|
175
175
|
# Protocol: sqs
|
|
176
|
-
# RawMessageDelivery: true
|
|
176
|
+
# RawMessageDelivery: true
|
|
177
177
|
# TopicArn: 'TODO: sourceSnsTopicArn'
|
|
178
178
|
|
|
179
179
|
DestinationTopic:
|
|
@@ -10,40 +10,6 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
"Resources": {
|
|
13
|
-
"datadogapikeysecret046FEF06": {
|
|
14
|
-
"DeletionPolicy": "Delete",
|
|
15
|
-
"Properties": {
|
|
16
|
-
"GenerateSecretString": {},
|
|
17
|
-
},
|
|
18
|
-
"Type": "AWS::SecretsManager::Secret",
|
|
19
|
-
"UpdateReplacePolicy": "Delete",
|
|
20
|
-
},
|
|
21
|
-
"destinationtopicDCE2E0B8": {
|
|
22
|
-
"Properties": {
|
|
23
|
-
"KmsMasterKeyId": {
|
|
24
|
-
"Fn::Join": [
|
|
25
|
-
"",
|
|
26
|
-
[
|
|
27
|
-
"arn:",
|
|
28
|
-
{
|
|
29
|
-
"Ref": "AWS::Partition",
|
|
30
|
-
},
|
|
31
|
-
":kms:",
|
|
32
|
-
{
|
|
33
|
-
"Ref": "AWS::Region",
|
|
34
|
-
},
|
|
35
|
-
":",
|
|
36
|
-
{
|
|
37
|
-
"Ref": "AWS::AccountId",
|
|
38
|
-
},
|
|
39
|
-
":alias/aws/sns",
|
|
40
|
-
],
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
"TopicName": "serviceName",
|
|
44
|
-
},
|
|
45
|
-
"Type": "AWS::SNS::Topic",
|
|
46
|
-
},
|
|
47
13
|
"kmskey49FBC3B3": {
|
|
48
14
|
"DeletionPolicy": "Retain",
|
|
49
15
|
"Properties": {
|
|
@@ -139,6 +105,17 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
139
105
|
},
|
|
140
106
|
"Resource": "*",
|
|
141
107
|
},
|
|
108
|
+
{
|
|
109
|
+
"Action": [
|
|
110
|
+
"kms:Decrypt",
|
|
111
|
+
"kms:GenerateDataKey",
|
|
112
|
+
],
|
|
113
|
+
"Effect": "Allow",
|
|
114
|
+
"Principal": {
|
|
115
|
+
"Service": "sns.amazonaws.com",
|
|
116
|
+
},
|
|
117
|
+
"Resource": "*",
|
|
118
|
+
},
|
|
142
119
|
],
|
|
143
120
|
"Version": "2012-10-17",
|
|
144
121
|
},
|
|
@@ -158,6 +135,9 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
158
135
|
},
|
|
159
136
|
"Type": "AWS::KMS::Alias",
|
|
160
137
|
},
|
|
138
|
+
"sourcetopic7C3DC892": {
|
|
139
|
+
"Type": "AWS::SNS::Topic",
|
|
140
|
+
},
|
|
161
141
|
"worker28EA3E30": {
|
|
162
142
|
"DependsOn": [
|
|
163
143
|
"workerServiceRoleDefaultPolicyBA498553",
|
|
@@ -176,9 +156,6 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
176
156
|
"Description": "Updated at 1212-12-12T12:12:12.121Z",
|
|
177
157
|
"Environment": {
|
|
178
158
|
"Variables": {
|
|
179
|
-
"DESTINATION_SNS_TOPIC_ARN": {
|
|
180
|
-
"Ref": "destinationtopicDCE2E0B8",
|
|
181
|
-
},
|
|
182
159
|
"ENVIRONMENT": "dev",
|
|
183
160
|
"NODE_ENV": "production",
|
|
184
161
|
"NODE_OPTIONS": "--enable-source-maps",
|
|
@@ -194,20 +171,6 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
194
171
|
"Arn",
|
|
195
172
|
],
|
|
196
173
|
},
|
|
197
|
-
"Layers": [
|
|
198
|
-
{
|
|
199
|
-
"Fn::Join": [
|
|
200
|
-
"",
|
|
201
|
-
[
|
|
202
|
-
"arn:aws:lambda:",
|
|
203
|
-
{
|
|
204
|
-
"Ref": "AWS::Region",
|
|
205
|
-
},
|
|
206
|
-
":464622532012:layer:Datadog-Extension-ARM:58",
|
|
207
|
-
],
|
|
208
|
-
],
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
174
|
"ReservedConcurrentExecutions": 2,
|
|
212
175
|
"Role": {
|
|
213
176
|
"Fn::GetAtt": [
|
|
@@ -648,6 +611,59 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
648
611
|
"Type": "AWS::SQS::Queue",
|
|
649
612
|
"UpdateReplacePolicy": "Delete",
|
|
650
613
|
},
|
|
614
|
+
"workerqueuePolicy97054CB4": {
|
|
615
|
+
"Properties": {
|
|
616
|
+
"PolicyDocument": {
|
|
617
|
+
"Statement": [
|
|
618
|
+
{
|
|
619
|
+
"Action": "sqs:SendMessage",
|
|
620
|
+
"Condition": {
|
|
621
|
+
"ArnEquals": {
|
|
622
|
+
"aws:SourceArn": {
|
|
623
|
+
"Ref": "sourcetopic7C3DC892",
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
"Effect": "Allow",
|
|
628
|
+
"Principal": {
|
|
629
|
+
"Service": "sns.amazonaws.com",
|
|
630
|
+
},
|
|
631
|
+
"Resource": {
|
|
632
|
+
"Fn::GetAtt": [
|
|
633
|
+
"workerqueueA05CE5C6",
|
|
634
|
+
"Arn",
|
|
635
|
+
],
|
|
636
|
+
},
|
|
637
|
+
},
|
|
638
|
+
],
|
|
639
|
+
"Version": "2012-10-17",
|
|
640
|
+
},
|
|
641
|
+
"Queues": [
|
|
642
|
+
{
|
|
643
|
+
"Ref": "workerqueueA05CE5C6",
|
|
644
|
+
},
|
|
645
|
+
],
|
|
646
|
+
},
|
|
647
|
+
"Type": "AWS::SQS::QueuePolicy",
|
|
648
|
+
},
|
|
649
|
+
"workerqueueappStacksourcetopic613C6BDBD2F224F5": {
|
|
650
|
+
"DependsOn": [
|
|
651
|
+
"workerqueuePolicy97054CB4",
|
|
652
|
+
],
|
|
653
|
+
"Properties": {
|
|
654
|
+
"Endpoint": {
|
|
655
|
+
"Fn::GetAtt": [
|
|
656
|
+
"workerqueueA05CE5C6",
|
|
657
|
+
"Arn",
|
|
658
|
+
],
|
|
659
|
+
},
|
|
660
|
+
"Protocol": "sqs",
|
|
661
|
+
"TopicArn": {
|
|
662
|
+
"Ref": "sourcetopic7C3DC892",
|
|
663
|
+
},
|
|
664
|
+
},
|
|
665
|
+
"Type": "AWS::SNS::Subscription",
|
|
666
|
+
},
|
|
651
667
|
"workerqueuedeadletters83F3505C": {
|
|
652
668
|
"DeletionPolicy": "Delete",
|
|
653
669
|
"Properties": {
|
|
@@ -703,40 +719,6 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
703
719
|
},
|
|
704
720
|
},
|
|
705
721
|
"Resources": {
|
|
706
|
-
"datadogapikeysecret046FEF06": {
|
|
707
|
-
"DeletionPolicy": "Delete",
|
|
708
|
-
"Properties": {
|
|
709
|
-
"GenerateSecretString": {},
|
|
710
|
-
},
|
|
711
|
-
"Type": "AWS::SecretsManager::Secret",
|
|
712
|
-
"UpdateReplacePolicy": "Delete",
|
|
713
|
-
},
|
|
714
|
-
"destinationtopicDCE2E0B8": {
|
|
715
|
-
"Properties": {
|
|
716
|
-
"KmsMasterKeyId": {
|
|
717
|
-
"Fn::Join": [
|
|
718
|
-
"",
|
|
719
|
-
[
|
|
720
|
-
"arn:",
|
|
721
|
-
{
|
|
722
|
-
"Ref": "AWS::Partition",
|
|
723
|
-
},
|
|
724
|
-
":kms:",
|
|
725
|
-
{
|
|
726
|
-
"Ref": "AWS::Region",
|
|
727
|
-
},
|
|
728
|
-
":",
|
|
729
|
-
{
|
|
730
|
-
"Ref": "AWS::AccountId",
|
|
731
|
-
},
|
|
732
|
-
":alias/aws/sns",
|
|
733
|
-
],
|
|
734
|
-
],
|
|
735
|
-
},
|
|
736
|
-
"TopicName": "serviceName",
|
|
737
|
-
},
|
|
738
|
-
"Type": "AWS::SNS::Topic",
|
|
739
|
-
},
|
|
740
722
|
"kmskey49FBC3B3": {
|
|
741
723
|
"DeletionPolicy": "Retain",
|
|
742
724
|
"Properties": {
|
|
@@ -832,6 +814,17 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
832
814
|
},
|
|
833
815
|
"Resource": "*",
|
|
834
816
|
},
|
|
817
|
+
{
|
|
818
|
+
"Action": [
|
|
819
|
+
"kms:Decrypt",
|
|
820
|
+
"kms:GenerateDataKey",
|
|
821
|
+
],
|
|
822
|
+
"Effect": "Allow",
|
|
823
|
+
"Principal": {
|
|
824
|
+
"Service": "sns.amazonaws.com",
|
|
825
|
+
},
|
|
826
|
+
"Resource": "*",
|
|
827
|
+
},
|
|
835
828
|
],
|
|
836
829
|
"Version": "2012-10-17",
|
|
837
830
|
},
|
|
@@ -851,6 +844,9 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
851
844
|
},
|
|
852
845
|
"Type": "AWS::KMS::Alias",
|
|
853
846
|
},
|
|
847
|
+
"sourcetopic7C3DC892": {
|
|
848
|
+
"Type": "AWS::SNS::Topic",
|
|
849
|
+
},
|
|
854
850
|
"worker28EA3E30": {
|
|
855
851
|
"DependsOn": [
|
|
856
852
|
"workerServiceRoleDefaultPolicyBA498553",
|
|
@@ -869,9 +865,6 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
869
865
|
"Description": "Updated at 1212-12-12T12:12:12.121Z",
|
|
870
866
|
"Environment": {
|
|
871
867
|
"Variables": {
|
|
872
|
-
"DESTINATION_SNS_TOPIC_ARN": {
|
|
873
|
-
"Ref": "destinationtopicDCE2E0B8",
|
|
874
|
-
},
|
|
875
868
|
"ENVIRONMENT": "prod",
|
|
876
869
|
"NODE_ENV": "production",
|
|
877
870
|
"NODE_OPTIONS": "--enable-source-maps",
|
|
@@ -887,20 +880,6 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
887
880
|
"Arn",
|
|
888
881
|
],
|
|
889
882
|
},
|
|
890
|
-
"Layers": [
|
|
891
|
-
{
|
|
892
|
-
"Fn::Join": [
|
|
893
|
-
"",
|
|
894
|
-
[
|
|
895
|
-
"arn:aws:lambda:",
|
|
896
|
-
{
|
|
897
|
-
"Ref": "AWS::Region",
|
|
898
|
-
},
|
|
899
|
-
":464622532012:layer:Datadog-Extension-ARM:58",
|
|
900
|
-
],
|
|
901
|
-
],
|
|
902
|
-
},
|
|
903
|
-
],
|
|
904
883
|
"ReservedConcurrentExecutions": 20,
|
|
905
884
|
"Role": {
|
|
906
885
|
"Fn::GetAtt": [
|
|
@@ -1341,6 +1320,59 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
1341
1320
|
"Type": "AWS::SQS::Queue",
|
|
1342
1321
|
"UpdateReplacePolicy": "Delete",
|
|
1343
1322
|
},
|
|
1323
|
+
"workerqueuePolicy97054CB4": {
|
|
1324
|
+
"Properties": {
|
|
1325
|
+
"PolicyDocument": {
|
|
1326
|
+
"Statement": [
|
|
1327
|
+
{
|
|
1328
|
+
"Action": "sqs:SendMessage",
|
|
1329
|
+
"Condition": {
|
|
1330
|
+
"ArnEquals": {
|
|
1331
|
+
"aws:SourceArn": {
|
|
1332
|
+
"Ref": "sourcetopic7C3DC892",
|
|
1333
|
+
},
|
|
1334
|
+
},
|
|
1335
|
+
},
|
|
1336
|
+
"Effect": "Allow",
|
|
1337
|
+
"Principal": {
|
|
1338
|
+
"Service": "sns.amazonaws.com",
|
|
1339
|
+
},
|
|
1340
|
+
"Resource": {
|
|
1341
|
+
"Fn::GetAtt": [
|
|
1342
|
+
"workerqueueA05CE5C6",
|
|
1343
|
+
"Arn",
|
|
1344
|
+
],
|
|
1345
|
+
},
|
|
1346
|
+
},
|
|
1347
|
+
],
|
|
1348
|
+
"Version": "2012-10-17",
|
|
1349
|
+
},
|
|
1350
|
+
"Queues": [
|
|
1351
|
+
{
|
|
1352
|
+
"Ref": "workerqueueA05CE5C6",
|
|
1353
|
+
},
|
|
1354
|
+
],
|
|
1355
|
+
},
|
|
1356
|
+
"Type": "AWS::SQS::QueuePolicy",
|
|
1357
|
+
},
|
|
1358
|
+
"workerqueueappStacksourcetopic613C6BDBD2F224F5": {
|
|
1359
|
+
"DependsOn": [
|
|
1360
|
+
"workerqueuePolicy97054CB4",
|
|
1361
|
+
],
|
|
1362
|
+
"Properties": {
|
|
1363
|
+
"Endpoint": {
|
|
1364
|
+
"Fn::GetAtt": [
|
|
1365
|
+
"workerqueueA05CE5C6",
|
|
1366
|
+
"Arn",
|
|
1367
|
+
],
|
|
1368
|
+
},
|
|
1369
|
+
"Protocol": "sqs",
|
|
1370
|
+
"TopicArn": {
|
|
1371
|
+
"Ref": "sourcetopic7C3DC892",
|
|
1372
|
+
},
|
|
1373
|
+
},
|
|
1374
|
+
"Type": "AWS::SNS::Subscription",
|
|
1375
|
+
},
|
|
1344
1376
|
"workerqueuedeadletters83F3505C": {
|
|
1345
1377
|
"DeletionPolicy": "Delete",
|
|
1346
1378
|
"Properties": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App,
|
|
1
|
+
import { App, aws_sns } from 'aws-cdk-lib';
|
|
2
2
|
import { Template } from 'aws-cdk-lib/assertions';
|
|
3
3
|
|
|
4
4
|
const currentDate = '1212-12-12T12:12:12.121Z';
|
|
@@ -36,12 +36,6 @@ it.each(['dev', 'prod'])(
|
|
|
36
36
|
.spyOn(aws_sns.Topic, 'fromTopicArn')
|
|
37
37
|
.mockImplementation((scope, id) => new aws_sns.Topic(scope, id));
|
|
38
38
|
|
|
39
|
-
jest
|
|
40
|
-
.spyOn(aws_secretsmanager.Secret, 'fromSecretPartialArn')
|
|
41
|
-
.mockImplementation(
|
|
42
|
-
(scope, id) => new aws_secretsmanager.Secret(scope, id),
|
|
43
|
-
);
|
|
44
|
-
|
|
45
39
|
const app = new App();
|
|
46
40
|
|
|
47
41
|
const stack = new AppStack(app, 'appStack');
|
|
@@ -53,18 +47,13 @@ it.each(['dev', 'prod'])(
|
|
|
53
47
|
/"S3Key":"([0-9a-f]+)\.zip"/g,
|
|
54
48
|
(_, hash) => `"S3Key":"${'x'.repeat(hash.length)}.zip"`,
|
|
55
49
|
)
|
|
56
|
-
.
|
|
50
|
+
.replaceAll(
|
|
57
51
|
/workerCurrentVersion([0-9a-zA-Z]+)"/g,
|
|
58
52
|
(_, hash) => `workerCurrentVersion${'x'.repeat(hash.length)}"`,
|
|
59
53
|
)
|
|
60
54
|
.replaceAll(
|
|
61
55
|
/"Value":"\d+\.\d+\.\d+-([^"]+)"/g,
|
|
62
56
|
(_, hash) => `"Value": "x.x.x-${'x'.repeat(hash.length)}"`,
|
|
63
|
-
)
|
|
64
|
-
.replace(
|
|
65
|
-
/"DD_TAGS":"git.commit.sha:([0-9a-f]+),git.repository_url:([^\"]+)"/g,
|
|
66
|
-
(_, sha, url) =>
|
|
67
|
-
`"DD_TAGS":"git.commit.sha:${'x'.repeat(sha.length)},git.repository_url:${'x'.repeat(url.length)}"`,
|
|
68
57
|
);
|
|
69
58
|
expect(JSON.parse(json)).toMatchSnapshot();
|
|
70
59
|
},
|
|
@@ -8,12 +8,11 @@ import {
|
|
|
8
8
|
aws_lambda,
|
|
9
9
|
aws_lambda_event_sources,
|
|
10
10
|
aws_lambda_nodejs,
|
|
11
|
-
aws_secretsmanager,
|
|
12
11
|
aws_sns,
|
|
12
|
+
aws_sns_subscriptions,
|
|
13
13
|
aws_sqs,
|
|
14
14
|
} from 'aws-cdk-lib';
|
|
15
15
|
import type { Construct } from 'constructs';
|
|
16
|
-
import { Datadog, getExtensionLayerArn } from 'datadog-cdk-constructs-v2';
|
|
17
16
|
|
|
18
17
|
import { config } from './config';
|
|
19
18
|
|
|
@@ -50,42 +49,13 @@ export class AppStack extends Stack {
|
|
|
50
49
|
encryptionMasterKey: kmsKey,
|
|
51
50
|
});
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
// this,
|
|
55
|
-
// 'source-topic',
|
|
56
|
-
// config.sourceSnsTopicArn,
|
|
57
|
-
// );
|
|
58
|
-
|
|
59
|
-
// topic.addSubscription(
|
|
60
|
-
// new aws_sns_subscriptions.SqsSubscription(queue, {
|
|
61
|
-
// rawMessageDelivery: true, // Remove this property if you require end to end datadog tracing
|
|
62
|
-
// }),
|
|
63
|
-
// );
|
|
64
|
-
|
|
65
|
-
const snsKey = aws_kms.Alias.fromAliasName(
|
|
52
|
+
const topic = aws_sns.Topic.fromTopicArn(
|
|
66
53
|
this,
|
|
67
|
-
'
|
|
68
|
-
|
|
54
|
+
'source-topic',
|
|
55
|
+
config.sourceSnsTopicArn,
|
|
69
56
|
);
|
|
70
57
|
|
|
71
|
-
|
|
72
|
-
masterKey: snsKey,
|
|
73
|
-
topicName: '<%- serviceName %>',
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const datadogSecret = aws_secretsmanager.Secret.fromSecretPartialArn(
|
|
77
|
-
this,
|
|
78
|
-
'datadog-api-key-secret',
|
|
79
|
-
config.datadogApiKeySecretArn,
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const datadog = new Datadog(this, 'datadog', {
|
|
83
|
-
apiKeySecret: datadogSecret,
|
|
84
|
-
addLayers: false,
|
|
85
|
-
enableDatadogLogs: false,
|
|
86
|
-
flushMetricsToLogs: false,
|
|
87
|
-
extensionLayerVersion: 58,
|
|
88
|
-
});
|
|
58
|
+
topic.addSubscription(new aws_sns_subscriptions.SqsSubscription(queue));
|
|
89
59
|
|
|
90
60
|
const architecture = '<%- lambdaCdkArchitecture %>';
|
|
91
61
|
|
|
@@ -115,33 +85,17 @@ export class AppStack extends Stack {
|
|
|
115
85
|
...defaultWorkerConfig,
|
|
116
86
|
entry: './src/app.ts',
|
|
117
87
|
timeout: Duration.seconds(30),
|
|
118
|
-
bundling:
|
|
119
|
-
...defaultWorkerBundlingConfig,
|
|
120
|
-
nodeModules: ['datadog-lambda-js', 'dd-trace'],
|
|
121
|
-
},
|
|
88
|
+
bundling: defaultWorkerBundlingConfig,
|
|
122
89
|
functionName: '<%- serviceName %>',
|
|
123
90
|
environment: {
|
|
124
91
|
...defaultWorkerEnvironment,
|
|
125
92
|
...config.workerLambda.environment,
|
|
126
|
-
DESTINATION_SNS_TOPIC_ARN: destinationTopic.topicArn,
|
|
127
93
|
},
|
|
128
94
|
// https://github.com/aws/aws-cdk/issues/28237
|
|
129
95
|
// This forces the lambda to be updated on every deployment
|
|
130
96
|
// If you do not wish to use hotswap, you can remove the new Date().toISOString() from the description
|
|
131
97
|
description: `Updated at ${new Date().toISOString()}`,
|
|
132
98
|
reservedConcurrentExecutions: config.workerLambda.reservedConcurrency,
|
|
133
|
-
layers: [
|
|
134
|
-
// Workaround for https://github.com/DataDog/datadog-cdk-constructs/issues/201
|
|
135
|
-
aws_lambda.LayerVersion.fromLayerVersionArn(
|
|
136
|
-
this,
|
|
137
|
-
'datadog-layer',
|
|
138
|
-
getExtensionLayerArn(
|
|
139
|
-
this.region,
|
|
140
|
-
datadog.props.extensionLayerVersion as number,
|
|
141
|
-
defaultWorkerConfig.architecture === aws_lambda.Architecture.ARM_64,
|
|
142
|
-
),
|
|
143
|
-
),
|
|
144
|
-
],
|
|
145
99
|
});
|
|
146
100
|
|
|
147
101
|
const workerDeployment = new LambdaDeployment(this, 'workerDeployment', {
|
|
@@ -16,7 +16,6 @@ interface Config {
|
|
|
16
16
|
VERSION: string;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
datadogApiKeySecretArn: string;
|
|
20
19
|
sourceSnsTopicArn: string;
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -31,7 +30,6 @@ const configs: Record<Environment, Config> = {
|
|
|
31
30
|
VERSION: Env.string('VERSION', { default: 'local' }),
|
|
32
31
|
},
|
|
33
32
|
},
|
|
34
|
-
datadogApiKeySecretArn: 'TODO: datadogApiKeySecretArn',
|
|
35
33
|
sourceSnsTopicArn: 'TODO: sourceSnsTopicArn',
|
|
36
34
|
},
|
|
37
35
|
prod: {
|
|
@@ -44,7 +42,6 @@ const configs: Record<Environment, Config> = {
|
|
|
44
42
|
VERSION: Env.string('VERSION', { default: 'local' }),
|
|
45
43
|
},
|
|
46
44
|
},
|
|
47
|
-
datadogApiKeySecretArn: 'TODO: datadogApiKeySecretArn',
|
|
48
45
|
sourceSnsTopicArn: 'TODO: sourceSnsTopicArn',
|
|
49
46
|
},
|
|
50
47
|
};
|
|
@@ -17,27 +17,20 @@
|
|
|
17
17
|
"@aws-sdk/client-lambda": "^3.363.0",
|
|
18
18
|
"@aws-sdk/client-sns": "^3.363.0",
|
|
19
19
|
"@seek/logger": "^9.0.0",
|
|
20
|
-
"datadog-lambda-js": "^8.0.0",
|
|
21
|
-
"dd-trace": "^5.0.0",
|
|
22
20
|
"skuba-dive": "^2.0.0",
|
|
23
21
|
"zod": "^3.19.1"
|
|
24
22
|
},
|
|
25
23
|
"devDependencies": {
|
|
26
24
|
"@seek/aws-codedeploy-infra": "^2.1.0",
|
|
27
25
|
"@types/aws-lambda": "^8.10.82",
|
|
28
|
-
"@types/chance": "^1.1.3",
|
|
29
26
|
"@types/node": "^20.16.5",
|
|
30
27
|
"aws-cdk": "^2.109.0",
|
|
31
28
|
"aws-cdk-lib": "^2.109.0",
|
|
32
|
-
"aws-sdk-client-mock": "^4.0.0",
|
|
33
|
-
"aws-sdk-client-mock-jest": "^4.0.0",
|
|
34
|
-
"chance": "^1.1.8",
|
|
35
29
|
"constructs": "^10.0.17",
|
|
36
|
-
"datadog-cdk-constructs-v2": "^1.13.0",
|
|
37
30
|
"pino-pretty": "^11.0.0",
|
|
38
|
-
"skuba": "
|
|
31
|
+
"skuba": "*"
|
|
39
32
|
},
|
|
40
|
-
"packageManager": "pnpm@9.
|
|
33
|
+
"packageManager": "pnpm@9.12.0",
|
|
41
34
|
"engines": {
|
|
42
35
|
"node": ">=20"
|
|
43
36
|
}
|