skuba 9.0.1 → 9.1.0-main-20241019031757
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 +2 -6
- package/lib/cli/lint/annotate/github/tsc.js +2 -12
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +1 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +35 -0
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +96 -0
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +7 -0
- package/lib/cli/test/reporters/github/annotations.js +3 -3
- package/lib/cli/test/reporters/github/annotations.js.map +2 -2
- package/package.json +5 -6
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/Dockerfile.dev-deps +3 -1
- package/template/express-rest-api/package.json +1 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/Dockerfile +3 -1
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/Dockerfile.dev-deps +3 -1
- package/template/koa-rest-api/package.json +1 -1
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker/Dockerfile +3 -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/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/.env +1 -0
- package/template/lambda-sqs-worker-cdk/Dockerfile +3 -1
- package/template/lambda-sqs-worker-cdk/README.md +145 -0
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +158 -136
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +18 -2
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +52 -25
- package/template/lambda-sqs-worker-cdk/infra/config.ts +3 -0
- package/template/lambda-sqs-worker-cdk/package.json +9 -2
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +116 -0
- package/template/lambda-sqs-worker-cdk/src/app.ts +43 -21
- package/template/lambda-sqs-worker-cdk/src/config.ts +15 -0
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +61 -0
- package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +43 -0
- package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +27 -0
- package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +14 -0
- package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +84 -0
- package/template/lambda-sqs-worker-cdk/src/framework/validation.ts +10 -0
- package/template/lambda-sqs-worker-cdk/src/mapping/jobScorer.ts +22 -0
- package/template/lambda-sqs-worker-cdk/src/services/aws.ts +5 -0
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +44 -0
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.ts +59 -0
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +40 -0
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.ts +33 -0
- package/template/lambda-sqs-worker-cdk/src/testing/handler.ts +13 -0
- package/template/lambda-sqs-worker-cdk/src/testing/logging.ts +19 -0
- package/template/lambda-sqs-worker-cdk/src/testing/services.ts +28 -0
- package/template/lambda-sqs-worker-cdk/src/testing/types.ts +33 -0
- package/template/lambda-sqs-worker-cdk/src/types/jobScorer.ts +15 -0
- package/template/lambda-sqs-worker-cdk/src/types/pipelineEvents.ts +21 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# <%- repoName %>
|
|
2
|
+
|
|
3
|
+
[](https://github.com/seek-oss/skuba)
|
|
4
|
+
|
|
5
|
+
Next steps:
|
|
6
|
+
|
|
7
|
+
1. [ ] Finish templating if this was skipped earlier:
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
pnpm exec skuba configure
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. [ ] Create a new repository in the appropriate GitHub organisation.
|
|
14
|
+
3. [ ] Add the repository to BuildAgency;
|
|
15
|
+
see our internal [Buildkite Docs] for more information.
|
|
16
|
+
4. [ ] Add Datadog extension, deployment bucket configuration and data classification tags to [infra/config.ts](infra/config.ts).
|
|
17
|
+
5. [ ] Push local commits to the upstream GitHub branch.
|
|
18
|
+
6. [ ] Configure [GitHub repository settings].
|
|
19
|
+
7. [ ] Delete this checklist 😌.
|
|
20
|
+
|
|
21
|
+
[Buildkite Docs]: https://backstage.myseek.xyz/docs/default/component/buildkite-docs
|
|
22
|
+
[GitHub repository settings]: https://github.com/<%-orgName%>/<%-repoName%>/settings
|
|
23
|
+
|
|
24
|
+
## Design
|
|
25
|
+
|
|
26
|
+
<%-repoName %> is a Node.js [Lambda] application built in line with our [Technical Guidelines].
|
|
27
|
+
It is backed by a typical SQS message + dead letter queue configuration and uses common SEEK packages.
|
|
28
|
+
Workers enable fault-tolerant asynchronous processing of events.
|
|
29
|
+
|
|
30
|
+
The `lambda-sqs-worker-cdk` template is modelled after a hypothetical enricher that scores job advertisements.
|
|
31
|
+
It's stubbed out with in-memory [scoring service](src/services/jobScorer.ts).
|
|
32
|
+
This would be replaced with internal logic or an external service in production.
|
|
33
|
+
|
|
34
|
+
This project is deployed with [AWS CDK].
|
|
35
|
+
The Lambda runtime provisions a single Node.js process per container.
|
|
36
|
+
The supplied [infra/appStack.ts](infra/appStack.ts) starts out with a minimal `memorySize` which may require tuning based on workload.
|
|
37
|
+
Under load, we autoscale horizontally in terms of container count up to `reservedConcurrency`.
|
|
38
|
+
|
|
39
|
+
[@seek/aws-codedeploy-hooks] configures [CodeDeploy] for a blue-green deployment approach.
|
|
40
|
+
A smoke test is run against the new version before traffic is switched over,
|
|
41
|
+
providing an opportunity to test access and connectivity to online dependencies.
|
|
42
|
+
This defaults to an invocation with an empty object `{}`.
|
|
43
|
+
|
|
44
|
+
## Development
|
|
45
|
+
|
|
46
|
+
### Test
|
|
47
|
+
|
|
48
|
+
```shell
|
|
49
|
+
# Run Jest tests locally
|
|
50
|
+
pnpm test
|
|
51
|
+
|
|
52
|
+
# Authenticate to dev account
|
|
53
|
+
awsauth
|
|
54
|
+
|
|
55
|
+
# Run smoke test against deployed application
|
|
56
|
+
ENVIRONMENT=dev pnpm smoke
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Lint
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
# Fix issues
|
|
63
|
+
pnpm format
|
|
64
|
+
|
|
65
|
+
# Check for issues
|
|
66
|
+
pnpm lint
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Start
|
|
70
|
+
|
|
71
|
+
```shell
|
|
72
|
+
# Start a local HTTP server
|
|
73
|
+
pnpm start
|
|
74
|
+
|
|
75
|
+
# Start with Node.js Inspector enabled
|
|
76
|
+
pnpm start:debug
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This serves the Lambda application over HTTP.
|
|
80
|
+
For example, to invoke the handler with an empty object `{}` for smoke testing:
|
|
81
|
+
|
|
82
|
+
```shell
|
|
83
|
+
curl --data '[{}, {"awsRequestId": "local"}]' --include localhost:<%- port %>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Deploy
|
|
87
|
+
|
|
88
|
+
This project is deployed through a [Buildkite pipeline](.buildkite/pipeline.yml).
|
|
89
|
+
|
|
90
|
+
- Commits to a feature branch can be deployed to the dev environment by unblocking a step in the Buildkite UI
|
|
91
|
+
- Commits to the default branch are automatically deployed to the dev and prod environments in sequence
|
|
92
|
+
|
|
93
|
+
To deploy locally:
|
|
94
|
+
|
|
95
|
+
```shell
|
|
96
|
+
# Authenticate to dev account
|
|
97
|
+
awsauth
|
|
98
|
+
|
|
99
|
+
ENVIRONMENT=dev pnpm run deploy
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
A hotswap deploy enables faster deployment but come with caveats such as requiring a Lambda to be rebuilt with every build.
|
|
103
|
+
|
|
104
|
+
To deploy a [hotswap]:
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
# Authenticate to dev account
|
|
108
|
+
awsauth
|
|
109
|
+
|
|
110
|
+
ENVIRONMENT=dev pnpm run deploy:hotswap
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
To rapidly roll back a change,
|
|
114
|
+
retry an individual deployment step from the previous build in Buildkite.
|
|
115
|
+
Note that this will introduce drift between the head of the default Git branch and the live environment;
|
|
116
|
+
use with caution and always follow up with a proper revert or fix in Git history.
|
|
117
|
+
|
|
118
|
+
## Support
|
|
119
|
+
|
|
120
|
+
### Dev
|
|
121
|
+
|
|
122
|
+
TODO: add support links for the dev environment.
|
|
123
|
+
|
|
124
|
+
<!--
|
|
125
|
+
- CloudWatch dashboard
|
|
126
|
+
- Datadog dashboard
|
|
127
|
+
- Splunk logs
|
|
128
|
+
-->
|
|
129
|
+
|
|
130
|
+
### Prod
|
|
131
|
+
|
|
132
|
+
TODO: add support links for the prod environment.
|
|
133
|
+
|
|
134
|
+
<!--
|
|
135
|
+
- CloudWatch dashboard
|
|
136
|
+
- Datadog dashboard
|
|
137
|
+
- Splunk logs
|
|
138
|
+
-->
|
|
139
|
+
|
|
140
|
+
[@seek/aws-codedeploy-hooks]: https://github.com/seek-oss/aws-codedeploy-hooks
|
|
141
|
+
[AWS CDK]: https://docs.aws.amazon.com/cdk/v2/guide/home.html
|
|
142
|
+
[CodeDeploy]: https://docs.aws.amazon.com/codedeploy
|
|
143
|
+
[Hotswap]: https://docs.aws.amazon.com/cdk/v2/guide/ref-cli-cmd-deploy.html#ref-cli-cmd-deploy-options
|
|
144
|
+
[Lambda]: https://docs.aws.amazon.com/lambda
|
|
145
|
+
[Technical Guidelines]: https://myseek.atlassian.net/wiki/spaces/AA/pages/2358346017/
|
|
@@ -10,6 +10,40 @@ 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
|
+
},
|
|
13
47
|
"kmskey49FBC3B3": {
|
|
14
48
|
"DeletionPolicy": "Retain",
|
|
15
49
|
"Properties": {
|
|
@@ -105,17 +139,6 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
105
139
|
},
|
|
106
140
|
"Resource": "*",
|
|
107
141
|
},
|
|
108
|
-
{
|
|
109
|
-
"Action": [
|
|
110
|
-
"kms:Decrypt",
|
|
111
|
-
"kms:GenerateDataKey",
|
|
112
|
-
],
|
|
113
|
-
"Effect": "Allow",
|
|
114
|
-
"Principal": {
|
|
115
|
-
"Service": "sns.amazonaws.com",
|
|
116
|
-
},
|
|
117
|
-
"Resource": "*",
|
|
118
|
-
},
|
|
119
142
|
],
|
|
120
143
|
"Version": "2012-10-17",
|
|
121
144
|
},
|
|
@@ -135,9 +158,6 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
135
158
|
},
|
|
136
159
|
"Type": "AWS::KMS::Alias",
|
|
137
160
|
},
|
|
138
|
-
"sourcetopic7C3DC892": {
|
|
139
|
-
"Type": "AWS::SNS::Topic",
|
|
140
|
-
},
|
|
141
161
|
"worker28EA3E30": {
|
|
142
162
|
"DependsOn": [
|
|
143
163
|
"workerServiceRoleDefaultPolicyBA498553",
|
|
@@ -156,6 +176,22 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
156
176
|
"Description": "Updated at 1212-12-12T12:12:12.121Z",
|
|
157
177
|
"Environment": {
|
|
158
178
|
"Variables": {
|
|
179
|
+
"DD_API_KEY_SECRET_ARN": {
|
|
180
|
+
"Ref": "datadogapikeysecret046FEF06",
|
|
181
|
+
},
|
|
182
|
+
"DD_CAPTURE_LAMBDA_PAYLOAD": "false",
|
|
183
|
+
"DD_FLUSH_TO_LOG": "false",
|
|
184
|
+
"DD_LAMBDA_HANDLER": "index.handler",
|
|
185
|
+
"DD_LOGS_INJECTION": "false",
|
|
186
|
+
"DD_MERGE_XRAY_TRACES": "false",
|
|
187
|
+
"DD_SERVERLESS_APPSEC_ENABLED": "false",
|
|
188
|
+
"DD_SERVERLESS_LOGS_ENABLED": "false",
|
|
189
|
+
"DD_SITE": "datadoghq.com",
|
|
190
|
+
"DD_TAGS": "git.commit.sha:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,git.repository_url:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
191
|
+
"DD_TRACE_ENABLED": "true",
|
|
192
|
+
"DESTINATION_SNS_TOPIC_ARN": {
|
|
193
|
+
"Ref": "destinationtopicDCE2E0B8",
|
|
194
|
+
},
|
|
159
195
|
"ENVIRONMENT": "dev",
|
|
160
196
|
"NODE_ENV": "production",
|
|
161
197
|
"NODE_OPTIONS": "--enable-source-maps",
|
|
@@ -164,13 +200,27 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
164
200
|
},
|
|
165
201
|
},
|
|
166
202
|
"FunctionName": "serviceName",
|
|
167
|
-
"Handler": "
|
|
203
|
+
"Handler": "node_modules/datadog-lambda-js/dist/handler.handler",
|
|
168
204
|
"KmsKeyArn": {
|
|
169
205
|
"Fn::GetAtt": [
|
|
170
206
|
"kmskey49FBC3B3",
|
|
171
207
|
"Arn",
|
|
172
208
|
],
|
|
173
209
|
},
|
|
210
|
+
"Layers": [
|
|
211
|
+
{
|
|
212
|
+
"Fn::Join": [
|
|
213
|
+
"",
|
|
214
|
+
[
|
|
215
|
+
"arn:aws:lambda:",
|
|
216
|
+
{
|
|
217
|
+
"Ref": "AWS::Region",
|
|
218
|
+
},
|
|
219
|
+
":464622532012:layer:Datadog-Extension-ARM:x",
|
|
220
|
+
],
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
],
|
|
174
224
|
"ReservedConcurrentExecutions": 2,
|
|
175
225
|
"Role": {
|
|
176
226
|
"Fn::GetAtt": [
|
|
@@ -184,6 +234,10 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
184
234
|
"Key": "aws-codedeploy-hooks",
|
|
185
235
|
"Value": "x.x.x-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
186
236
|
},
|
|
237
|
+
{
|
|
238
|
+
"Key": "dd_cdk_construct",
|
|
239
|
+
"Value": "vx.x.x",
|
|
240
|
+
},
|
|
187
241
|
],
|
|
188
242
|
"Timeout": 30,
|
|
189
243
|
},
|
|
@@ -550,6 +604,16 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
550
604
|
"Properties": {
|
|
551
605
|
"PolicyDocument": {
|
|
552
606
|
"Statement": [
|
|
607
|
+
{
|
|
608
|
+
"Action": [
|
|
609
|
+
"secretsmanager:GetSecretValue",
|
|
610
|
+
"secretsmanager:DescribeSecret",
|
|
611
|
+
],
|
|
612
|
+
"Effect": "Allow",
|
|
613
|
+
"Resource": {
|
|
614
|
+
"Ref": "datadogapikeysecret046FEF06",
|
|
615
|
+
},
|
|
616
|
+
},
|
|
553
617
|
{
|
|
554
618
|
"Action": [
|
|
555
619
|
"sqs:ReceiveMessage",
|
|
@@ -611,59 +675,6 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
|
|
|
611
675
|
"Type": "AWS::SQS::Queue",
|
|
612
676
|
"UpdateReplacePolicy": "Delete",
|
|
613
677
|
},
|
|
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
|
-
},
|
|
667
678
|
"workerqueuedeadletters83F3505C": {
|
|
668
679
|
"DeletionPolicy": "Delete",
|
|
669
680
|
"Properties": {
|
|
@@ -719,6 +730,40 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
719
730
|
},
|
|
720
731
|
},
|
|
721
732
|
"Resources": {
|
|
733
|
+
"datadogapikeysecret046FEF06": {
|
|
734
|
+
"DeletionPolicy": "Delete",
|
|
735
|
+
"Properties": {
|
|
736
|
+
"GenerateSecretString": {},
|
|
737
|
+
},
|
|
738
|
+
"Type": "AWS::SecretsManager::Secret",
|
|
739
|
+
"UpdateReplacePolicy": "Delete",
|
|
740
|
+
},
|
|
741
|
+
"destinationtopicDCE2E0B8": {
|
|
742
|
+
"Properties": {
|
|
743
|
+
"KmsMasterKeyId": {
|
|
744
|
+
"Fn::Join": [
|
|
745
|
+
"",
|
|
746
|
+
[
|
|
747
|
+
"arn:",
|
|
748
|
+
{
|
|
749
|
+
"Ref": "AWS::Partition",
|
|
750
|
+
},
|
|
751
|
+
":kms:",
|
|
752
|
+
{
|
|
753
|
+
"Ref": "AWS::Region",
|
|
754
|
+
},
|
|
755
|
+
":",
|
|
756
|
+
{
|
|
757
|
+
"Ref": "AWS::AccountId",
|
|
758
|
+
},
|
|
759
|
+
":alias/aws/sns",
|
|
760
|
+
],
|
|
761
|
+
],
|
|
762
|
+
},
|
|
763
|
+
"TopicName": "serviceName",
|
|
764
|
+
},
|
|
765
|
+
"Type": "AWS::SNS::Topic",
|
|
766
|
+
},
|
|
722
767
|
"kmskey49FBC3B3": {
|
|
723
768
|
"DeletionPolicy": "Retain",
|
|
724
769
|
"Properties": {
|
|
@@ -814,17 +859,6 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
814
859
|
},
|
|
815
860
|
"Resource": "*",
|
|
816
861
|
},
|
|
817
|
-
{
|
|
818
|
-
"Action": [
|
|
819
|
-
"kms:Decrypt",
|
|
820
|
-
"kms:GenerateDataKey",
|
|
821
|
-
],
|
|
822
|
-
"Effect": "Allow",
|
|
823
|
-
"Principal": {
|
|
824
|
-
"Service": "sns.amazonaws.com",
|
|
825
|
-
},
|
|
826
|
-
"Resource": "*",
|
|
827
|
-
},
|
|
828
862
|
],
|
|
829
863
|
"Version": "2012-10-17",
|
|
830
864
|
},
|
|
@@ -844,9 +878,6 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
844
878
|
},
|
|
845
879
|
"Type": "AWS::KMS::Alias",
|
|
846
880
|
},
|
|
847
|
-
"sourcetopic7C3DC892": {
|
|
848
|
-
"Type": "AWS::SNS::Topic",
|
|
849
|
-
},
|
|
850
881
|
"worker28EA3E30": {
|
|
851
882
|
"DependsOn": [
|
|
852
883
|
"workerServiceRoleDefaultPolicyBA498553",
|
|
@@ -865,6 +896,22 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
865
896
|
"Description": "Updated at 1212-12-12T12:12:12.121Z",
|
|
866
897
|
"Environment": {
|
|
867
898
|
"Variables": {
|
|
899
|
+
"DD_API_KEY_SECRET_ARN": {
|
|
900
|
+
"Ref": "datadogapikeysecret046FEF06",
|
|
901
|
+
},
|
|
902
|
+
"DD_CAPTURE_LAMBDA_PAYLOAD": "false",
|
|
903
|
+
"DD_FLUSH_TO_LOG": "false",
|
|
904
|
+
"DD_LAMBDA_HANDLER": "index.handler",
|
|
905
|
+
"DD_LOGS_INJECTION": "false",
|
|
906
|
+
"DD_MERGE_XRAY_TRACES": "false",
|
|
907
|
+
"DD_SERVERLESS_APPSEC_ENABLED": "false",
|
|
908
|
+
"DD_SERVERLESS_LOGS_ENABLED": "false",
|
|
909
|
+
"DD_SITE": "datadoghq.com",
|
|
910
|
+
"DD_TAGS": "git.commit.sha:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,git.repository_url:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
911
|
+
"DD_TRACE_ENABLED": "true",
|
|
912
|
+
"DESTINATION_SNS_TOPIC_ARN": {
|
|
913
|
+
"Ref": "destinationtopicDCE2E0B8",
|
|
914
|
+
},
|
|
868
915
|
"ENVIRONMENT": "prod",
|
|
869
916
|
"NODE_ENV": "production",
|
|
870
917
|
"NODE_OPTIONS": "--enable-source-maps",
|
|
@@ -873,13 +920,27 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
873
920
|
},
|
|
874
921
|
},
|
|
875
922
|
"FunctionName": "serviceName",
|
|
876
|
-
"Handler": "
|
|
923
|
+
"Handler": "node_modules/datadog-lambda-js/dist/handler.handler",
|
|
877
924
|
"KmsKeyArn": {
|
|
878
925
|
"Fn::GetAtt": [
|
|
879
926
|
"kmskey49FBC3B3",
|
|
880
927
|
"Arn",
|
|
881
928
|
],
|
|
882
929
|
},
|
|
930
|
+
"Layers": [
|
|
931
|
+
{
|
|
932
|
+
"Fn::Join": [
|
|
933
|
+
"",
|
|
934
|
+
[
|
|
935
|
+
"arn:aws:lambda:",
|
|
936
|
+
{
|
|
937
|
+
"Ref": "AWS::Region",
|
|
938
|
+
},
|
|
939
|
+
":464622532012:layer:Datadog-Extension-ARM:x",
|
|
940
|
+
],
|
|
941
|
+
],
|
|
942
|
+
},
|
|
943
|
+
],
|
|
883
944
|
"ReservedConcurrentExecutions": 20,
|
|
884
945
|
"Role": {
|
|
885
946
|
"Fn::GetAtt": [
|
|
@@ -893,6 +954,10 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
893
954
|
"Key": "aws-codedeploy-hooks",
|
|
894
955
|
"Value": "x.x.x-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
895
956
|
},
|
|
957
|
+
{
|
|
958
|
+
"Key": "dd_cdk_construct",
|
|
959
|
+
"Value": "vx.x.x",
|
|
960
|
+
},
|
|
896
961
|
],
|
|
897
962
|
"Timeout": 30,
|
|
898
963
|
},
|
|
@@ -1259,6 +1324,16 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
1259
1324
|
"Properties": {
|
|
1260
1325
|
"PolicyDocument": {
|
|
1261
1326
|
"Statement": [
|
|
1327
|
+
{
|
|
1328
|
+
"Action": [
|
|
1329
|
+
"secretsmanager:GetSecretValue",
|
|
1330
|
+
"secretsmanager:DescribeSecret",
|
|
1331
|
+
],
|
|
1332
|
+
"Effect": "Allow",
|
|
1333
|
+
"Resource": {
|
|
1334
|
+
"Ref": "datadogapikeysecret046FEF06",
|
|
1335
|
+
},
|
|
1336
|
+
},
|
|
1262
1337
|
{
|
|
1263
1338
|
"Action": [
|
|
1264
1339
|
"sqs:ReceiveMessage",
|
|
@@ -1320,59 +1395,6 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
|
|
|
1320
1395
|
"Type": "AWS::SQS::Queue",
|
|
1321
1396
|
"UpdateReplacePolicy": "Delete",
|
|
1322
1397
|
},
|
|
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
|
-
},
|
|
1376
1398
|
"workerqueuedeadletters83F3505C": {
|
|
1377
1399
|
"DeletionPolicy": "Delete",
|
|
1378
1400
|
"Properties": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App, aws_sns } from 'aws-cdk-lib';
|
|
1
|
+
import { App, aws_secretsmanager, 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,6 +36,12 @@ 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
|
+
|
|
39
45
|
const app = new App();
|
|
40
46
|
|
|
41
47
|
const stack = new AppStack(app, 'appStack');
|
|
@@ -47,13 +53,23 @@ it.each(['dev', 'prod'])(
|
|
|
47
53
|
/"S3Key":"([0-9a-f]+)\.zip"/g,
|
|
48
54
|
(_, hash) => `"S3Key":"${'x'.repeat(hash.length)}.zip"`,
|
|
49
55
|
)
|
|
50
|
-
.
|
|
56
|
+
.replace(
|
|
51
57
|
/workerCurrentVersion([0-9a-zA-Z]+)"/g,
|
|
52
58
|
(_, hash) => `workerCurrentVersion${'x'.repeat(hash.length)}"`,
|
|
53
59
|
)
|
|
54
60
|
.replaceAll(
|
|
55
61
|
/"Value":"\d+\.\d+\.\d+-([^"]+)"/g,
|
|
56
62
|
(_, hash) => `"Value": "x.x.x-${'x'.repeat(hash.length)}"`,
|
|
63
|
+
)
|
|
64
|
+
.replaceAll(/"Value":"v\d+\.\d+\.\d+"/g, (_) => `"Value": "vx.x.x"`)
|
|
65
|
+
.replace(
|
|
66
|
+
/"DD_TAGS":"git.commit.sha:([0-9a-f]+),git.repository_url:([^\"]+)"/g,
|
|
67
|
+
(_, sha, url) =>
|
|
68
|
+
`"DD_TAGS":"git.commit.sha:${'x'.repeat(sha.length)},git.repository_url:${'x'.repeat(url.length)}"`,
|
|
69
|
+
)
|
|
70
|
+
.replaceAll(
|
|
71
|
+
/(layer:Datadog-Extension-.+?:)\d+/g,
|
|
72
|
+
(_, layer) => `${layer}x`,
|
|
57
73
|
);
|
|
58
74
|
expect(JSON.parse(json)).toMatchSnapshot();
|
|
59
75
|
},
|