Skip to content

Commit b1c9ab2

Browse files
authored
fix(lambda-nodejs): pnpm no longer supports nodejs14.x (#24821)
Doing a couple of things - Update `Dockerfile` image to nodejs18 - Pin pnpm to 8.0.0 (latest version) - Add some error handling to the test to better catch this error in the future ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 07d3aa7 commit b1c9ab2

File tree

267 files changed

+43967
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+43967
-236
lines changed

packages/@aws-cdk/aws-lambda-nodejs/lib/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# The correct AWS SAM build image based on the runtime of the function will be
22
# passed as build arg. The default allows to do `docker build .` when testing.
3-
ARG IMAGE=public.ecr.aws/sam/build-nodejs14.x
3+
ARG IMAGE=public.ecr.aws/sam/build-nodejs18.x
44
FROM $IMAGE
55

66
# Install yarn
77
RUN npm install --global [email protected]
88

99
# Install pnpm
10-
RUN npm install --global pnpm
10+
RUN npm install --global pnpm@8.0.0
1111

1212
# Install typescript
1313
RUN npm install --global typescript

packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import * as path from 'path';
33

44
const docker = process.env.CDK_DOCKER ?? 'docker';
55
beforeAll(() => {
6-
spawnSync(docker, ['build', '-t', 'esbuild', path.join(__dirname, '../lib')]);
6+
const process = spawnSync(docker, ['build', '-t', 'esbuild', path.join(__dirname, '../lib')], { stdio: 'inherit' });
7+
expect(process.error).toBeUndefined();
8+
expect(process.status).toBe(0);
79
});
810

911
test('esbuild is available', () => {

packages/@aws-cdk/aws-lambda-nodejs/test/integ.compilations.js.snapshot/cdk-integ-compilations-lambda-nodejs.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"files": {
44
"8df6c4f7f61921e6f88f328521b8a71aef10b045b77847bd61cfe75cf3a64c32": {
55
"source": {
@@ -14,15 +14,15 @@
1414
}
1515
}
1616
},
17-
"a5fb46bb5c70411499bb17cafda8537c5326fc1a8fee6822310feef3f2ec18da": {
17+
"f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7": {
1818
"source": {
1919
"path": "cdk-integ-compilations-lambda-nodejs.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "a5fb46bb5c70411499bb17cafda8537c5326fc1a8fee6822310feef3f2ec18da.json",
25+
"objectKey": "f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk/aws-lambda-nodejs/test/integ.compilations.js.snapshot/cdk-integ-compilations-lambda-nodejs.template.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
}
5353
},
5454
"Handler": "index.handler",
55-
"Runtime": "nodejs14.x"
55+
"Runtime": "nodejs16.x"
5656
},
5757
"DependsOn": [
5858
"tsdecoratorhandlerServiceRole61E9E52C"
@@ -110,7 +110,7 @@
110110
}
111111
},
112112
"Handler": "index.handler",
113-
"Runtime": "nodejs14.x"
113+
"Runtime": "nodejs16.x"
114114
},
115115
"DependsOn": [
116116
"tsdecoratorhandlertsconfigServiceRoleC4AE481E"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"20.0.0"}
1+
{"version":"31.0.0"}

packages/@aws-cdk/aws-lambda-nodejs/test/integ.compilations.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"testCases": {
44
"integ.compilations": {
55
"stacks": [

packages/@aws-cdk/aws-lambda-nodejs/test/integ.compilations.js.snapshot/manifest.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
2-
"version": "20.0.0",
2+
"version": "31.0.0",
33
"artifacts": {
4-
"Tree": {
5-
"type": "cdk:tree",
6-
"properties": {
7-
"file": "tree.json"
8-
}
9-
},
104
"cdk-integ-compilations-lambda-nodejs.assets": {
115
"type": "cdk:asset-manifest",
126
"properties": {
@@ -23,7 +17,7 @@
2317
"validateOnSynth": false,
2418
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
2519
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a5fb46bb5c70411499bb17cafda8537c5326fc1a8fee6822310feef3f2ec18da.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
2721
"requiresBootstrapStackVersion": 6,
2822
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2923
"additionalDependencies": [
@@ -77,6 +71,12 @@
7771
]
7872
},
7973
"displayName": "cdk-integ-compilations-lambda-nodejs"
74+
},
75+
"Tree": {
76+
"type": "cdk:tree",
77+
"properties": {
78+
"file": "tree.json"
79+
}
8080
}
8181
}
8282
}

packages/@aws-cdk/aws-lambda-nodejs/test/integ.compilations.js.snapshot/tree.json

+46-14
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
"id": "App",
55
"path": "",
66
"children": {
7-
"Tree": {
8-
"id": "Tree",
9-
"path": "Tree",
10-
"constructInfo": {
11-
"fqn": "constructs.Construct",
12-
"version": "10.1.85"
13-
}
14-
},
157
"cdk-integ-compilations-lambda-nodejs": {
168
"id": "cdk-integ-compilations-lambda-nodejs",
179
"path": "cdk-integ-compilations-lambda-nodejs",
@@ -24,6 +16,14 @@
2416
"id": "ServiceRole",
2517
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole",
2618
"children": {
19+
"ImportServiceRole": {
20+
"id": "ImportServiceRole",
21+
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole/ImportServiceRole",
22+
"constructInfo": {
23+
"fqn": "constructs.Construct",
24+
"version": "10.1.270"
25+
}
26+
},
2727
"Resource": {
2828
"id": "Resource",
2929
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole/Resource",
@@ -78,7 +78,7 @@
7878
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/Code/Stage",
7979
"constructInfo": {
8080
"fqn": "constructs.Construct",
81-
"version": "10.1.85"
81+
"version": "10.1.270"
8282
}
8383
},
8484
"AssetBucket": {
@@ -119,7 +119,7 @@
119119
}
120120
},
121121
"handler": "index.handler",
122-
"runtime": "nodejs14.x"
122+
"runtime": "nodejs16.x"
123123
}
124124
},
125125
"constructInfo": {
@@ -141,6 +141,14 @@
141141
"id": "ServiceRole",
142142
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole",
143143
"children": {
144+
"ImportServiceRole": {
145+
"id": "ImportServiceRole",
146+
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole/ImportServiceRole",
147+
"constructInfo": {
148+
"fqn": "constructs.Construct",
149+
"version": "10.1.270"
150+
}
151+
},
144152
"Resource": {
145153
"id": "Resource",
146154
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole/Resource",
@@ -195,7 +203,7 @@
195203
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/Code/Stage",
196204
"constructInfo": {
197205
"fqn": "constructs.Construct",
198-
"version": "10.1.85"
206+
"version": "10.1.270"
199207
}
200208
},
201209
"AssetBucket": {
@@ -236,7 +244,7 @@
236244
}
237245
},
238246
"handler": "index.handler",
239-
"runtime": "nodejs14.x"
247+
"runtime": "nodejs16.x"
240248
}
241249
},
242250
"constructInfo": {
@@ -249,17 +257,41 @@
249257
"fqn": "@aws-cdk/aws-lambda-nodejs.NodejsFunction",
250258
"version": "0.0.0"
251259
}
260+
},
261+
"BootstrapVersion": {
262+
"id": "BootstrapVersion",
263+
"path": "cdk-integ-compilations-lambda-nodejs/BootstrapVersion",
264+
"constructInfo": {
265+
"fqn": "constructs.Construct",
266+
"version": "10.1.270"
267+
}
268+
},
269+
"CheckBootstrapVersion": {
270+
"id": "CheckBootstrapVersion",
271+
"path": "cdk-integ-compilations-lambda-nodejs/CheckBootstrapVersion",
272+
"constructInfo": {
273+
"fqn": "constructs.Construct",
274+
"version": "10.1.270"
275+
}
252276
}
253277
},
254278
"constructInfo": {
255279
"fqn": "constructs.Construct",
256-
"version": "10.1.85"
280+
"version": "10.1.270"
281+
}
282+
},
283+
"Tree": {
284+
"id": "Tree",
285+
"path": "Tree",
286+
"constructInfo": {
287+
"fqn": "constructs.Construct",
288+
"version": "10.1.270"
257289
}
258290
}
259291
},
260292
"constructInfo": {
261293
"fqn": "constructs.Construct",
262-
"version": "10.1.85"
294+
"version": "10.1.270"
263295
}
264296
}
265297
}

packages/@aws-cdk/aws-lambda-nodejs/test/integ.compilations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestStack extends Stack {
1616
sourceMapMode: lambda.SourceMapMode.BOTH,
1717
preCompilation: true,
1818
},
19-
runtime: Runtime.NODEJS_14_X,
19+
runtime: Runtime.NODEJS_16_X,
2020
});
2121

2222
new lambda.NodejsFunction(this, 'ts-decorator-handler-tsconfig', {
@@ -28,7 +28,7 @@ class TestStack extends Stack {
2828
tsconfig: path.join(__dirname, '..', 'tsconfig.json'),
2929
preCompilation: true,
3030
},
31-
runtime: Runtime.NODEJS_14_X,
31+
runtime: Runtime.NODEJS_16_X,
3232
});
3333
}
3434
}

packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies-pnpm.js.snapshot/PnpmTestDefaultTestDeployAssert397EDF83.assets.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"version": "29.0.0",
2+
"version": "31.0.0",
33
"files": {
4-
"1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28": {
4+
"92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19": {
55
"source": {
6-
"path": "asset.1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.bundle",
6+
"path": "asset.92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19.bundle",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip",
12+
"objectKey": "92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb": {
17+
"e111cb956f29a2b7cd7d36c451cdc4ae7b2064621161ae1c7ed320f9588c32c3": {
1818
"source": {
1919
"path": "PnpmTestDefaultTestDeployAssert397EDF83.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb.json",
25+
"objectKey": "e111cb956f29a2b7cd7d36c451cdc4ae7b2064621161ae1c7ed320f9588c32c3.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies-pnpm.js.snapshot/PnpmTestDefaultTestDeployAssert397EDF83.template.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
},
2020
"flattenResponse": "false",
21-
"salt": "1674225978419"
21+
"salt": "1680010885937"
2222
},
2323
"UpdateReplacePolicy": "Delete",
2424
"DeletionPolicy": "Delete"
@@ -118,7 +118,7 @@
118118
"S3Bucket": {
119119
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
120120
},
121-
"S3Key": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip"
121+
"S3Key": "92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19.zip"
122122
},
123123
"Timeout": 120,
124124
"Handler": "index.handler",

packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies-pnpm.js.snapshot/TestStack.assets.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"version": "29.0.0",
2+
"version": "31.0.0",
33
"files": {
4-
"b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9": {
4+
"955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6": {
55
"source": {
6-
"path": "asset.b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9",
6+
"path": "asset.955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip",
12+
"objectKey": "955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327": {
17+
"fd2be9a57cb09bafce34463e8e77756fdb6fc10f343359b50f8ec5a4a847374e": {
1818
"source": {
1919
"path": "TestStack.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327.json",
25+
"objectKey": "fd2be9a57cb09bafce34463e8e77756fdb6fc10f343359b50f8ec5a4a847374e.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies-pnpm.js.snapshot/TestStack.template.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"S3Bucket": {
3939
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
4040
},
41-
"S3Key": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip"
41+
"S3Key": "955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6.zip"
4242
},
4343
"Role": {
4444
"Fn::GetAtt": [
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,10 @@ var CustomResourceHandler = class {
828828
hostname: parsedUrl.hostname,
829829
path: parsedUrl.path,
830830
method: "PUT",
831-
headers: { "content-type": "", "content-length": responseBody.length }
831+
headers: {
832+
"content-type": "",
833+
"content-length": Buffer.byteLength(responseBody, "utf8")
834+
}
832835
};
833836
return new Promise((resolve, reject) => {
834837
try {
@@ -983,7 +986,7 @@ function decodeCall(call) {
983986
try {
984987
const parsed = JSON.parse(call);
985988
return parsed;
986-
} catch (e) {
989+
} catch {
987990
return call;
988991
}
989992
}

0 commit comments

Comments
 (0)