Skip to content

Commit

Permalink
fix(lambda-nodejs): pnpm no longer supports nodejs14.x (#24821)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
corymhall committed Mar 28, 2023
1 parent c13a0f1 commit a8e9370
Show file tree
Hide file tree
Showing 267 changed files with 43,967 additions and 236 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/Dockerfile
@@ -1,13 +1,13 @@
# The correct AWS SAM build image based on the runtime of the function will be
# passed as build arg. The default allows to do `docker build .` when testing.
ARG IMAGE=public.ecr.aws/sam/build-nodejs14.x
ARG IMAGE=public.ecr.aws/sam/build-nodejs18.x
FROM $IMAGE

# Install yarn
RUN npm install --global yarn@1.22.5

# Install pnpm
RUN npm install --global pnpm
RUN npm install --global pnpm@8.0.0

# Install typescript
RUN npm install --global typescript
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts
Expand Up @@ -3,7 +3,9 @@ import * as path from 'path';

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

test('esbuild is available', () => {
Expand Down
@@ -1,5 +1,5 @@
{
"version": "20.0.0",
"version": "31.0.0",
"files": {
"8df6c4f7f61921e6f88f328521b8a71aef10b045b77847bd61cfe75cf3a64c32": {
"source": {
Expand All @@ -14,15 +14,15 @@
}
}
},
"a5fb46bb5c70411499bb17cafda8537c5326fc1a8fee6822310feef3f2ec18da": {
"f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7": {
"source": {
"path": "cdk-integ-compilations-lambda-nodejs.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "a5fb46bb5c70411499bb17cafda8537c5326fc1a8fee6822310feef3f2ec18da.json",
"objectKey": "f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Expand Up @@ -52,7 +52,7 @@
}
},
"Handler": "index.handler",
"Runtime": "nodejs14.x"
"Runtime": "nodejs16.x"
},
"DependsOn": [
"tsdecoratorhandlerServiceRole61E9E52C"
Expand Down Expand Up @@ -110,7 +110,7 @@
}
},
"Handler": "index.handler",
"Runtime": "nodejs14.x"
"Runtime": "nodejs16.x"
},
"DependsOn": [
"tsdecoratorhandlertsconfigServiceRoleC4AE481E"
Expand Down
@@ -1 +1 @@
{"version":"20.0.0"}
{"version":"31.0.0"}
@@ -1,5 +1,5 @@
{
"version": "20.0.0",
"version": "31.0.0",
"testCases": {
"integ.compilations": {
"stacks": [
Expand Down
@@ -1,12 +1,6 @@
{
"version": "20.0.0",
"version": "31.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"cdk-integ-compilations-lambda-nodejs.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand All @@ -23,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a5fb46bb5c70411499bb17cafda8537c5326fc1a8fee6822310feef3f2ec18da.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -77,6 +71,12 @@
]
},
"displayName": "cdk-integ-compilations-lambda-nodejs"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Expand Up @@ -4,14 +4,6 @@
"id": "App",
"path": "",
"children": {
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
}
},
"cdk-integ-compilations-lambda-nodejs": {
"id": "cdk-integ-compilations-lambda-nodejs",
"path": "cdk-integ-compilations-lambda-nodejs",
Expand All @@ -24,6 +16,14 @@
"id": "ServiceRole",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole",
"children": {
"ImportServiceRole": {
"id": "ImportServiceRole",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole/ImportServiceRole",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
}
},
"Resource": {
"id": "Resource",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole/Resource",
Expand Down Expand Up @@ -78,7 +78,7 @@
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/Code/Stage",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.270"
}
},
"AssetBucket": {
Expand Down Expand Up @@ -119,7 +119,7 @@
}
},
"handler": "index.handler",
"runtime": "nodejs14.x"
"runtime": "nodejs16.x"
}
},
"constructInfo": {
Expand All @@ -141,6 +141,14 @@
"id": "ServiceRole",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole",
"children": {
"ImportServiceRole": {
"id": "ImportServiceRole",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole/ImportServiceRole",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
}
},
"Resource": {
"id": "Resource",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole/Resource",
Expand Down Expand Up @@ -195,7 +203,7 @@
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/Code/Stage",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.270"
}
},
"AssetBucket": {
Expand Down Expand Up @@ -236,7 +244,7 @@
}
},
"handler": "index.handler",
"runtime": "nodejs14.x"
"runtime": "nodejs16.x"
}
},
"constructInfo": {
Expand All @@ -249,17 +257,41 @@
"fqn": "@aws-cdk/aws-lambda-nodejs.NodejsFunction",
"version": "0.0.0"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "cdk-integ-compilations-lambda-nodejs/BootstrapVersion",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "cdk-integ-compilations-lambda-nodejs/CheckBootstrapVersion",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.270"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.270"
}
}
}
Expand Up @@ -16,7 +16,7 @@ class TestStack extends Stack {
sourceMapMode: lambda.SourceMapMode.BOTH,
preCompilation: true,
},
runtime: Runtime.NODEJS_14_X,
runtime: Runtime.NODEJS_16_X,
});

new lambda.NodejsFunction(this, 'ts-decorator-handler-tsconfig', {
Expand All @@ -28,7 +28,7 @@ class TestStack extends Stack {
tsconfig: path.join(__dirname, '..', 'tsconfig.json'),
preCompilation: true,
},
runtime: Runtime.NODEJS_14_X,
runtime: Runtime.NODEJS_16_X,
});
}
}
Expand Down
@@ -1,28 +1,28 @@
{
"version": "29.0.0",
"version": "31.0.0",
"files": {
"1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28": {
"92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19": {
"source": {
"path": "asset.1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.bundle",
"path": "asset.92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip",
"objectKey": "92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb": {
"e111cb956f29a2b7cd7d36c451cdc4ae7b2064621161ae1c7ed320f9588c32c3": {
"source": {
"path": "PnpmTestDefaultTestDeployAssert397EDF83.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "2bd77eb3d8c517d922b9b5e7829e28b113dacc2d80176588fcc5608794a14ffb.json",
"objectKey": "e111cb956f29a2b7cd7d36c451cdc4ae7b2064621161ae1c7ed320f9588c32c3.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Expand Up @@ -18,7 +18,7 @@
}
},
"flattenResponse": "false",
"salt": "1674225978419"
"salt": "1680010885937"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -118,7 +118,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "1f3c2cfb18e102edc713fe4c4b4d87572f4297ee4a5e80a5960adf526ee9ea28.zip"
"S3Key": "92ec9d050245fd270cf2b0df478b31f140ba820c3407e964246946bcea933a19.zip"
},
"Timeout": 120,
"Handler": "index.handler",
Expand Down
@@ -1,28 +1,28 @@
{
"version": "29.0.0",
"version": "31.0.0",
"files": {
"b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9": {
"955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6": {
"source": {
"path": "asset.b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9",
"path": "asset.955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip",
"objectKey": "955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327": {
"fd2be9a57cb09bafce34463e8e77756fdb6fc10f343359b50f8ec5a4a847374e": {
"source": {
"path": "TestStack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "b6922a50679c4b55d94ce943a6cc9a0e1d67006def01191f71eb7e05bfe18327.json",
"objectKey": "fd2be9a57cb09bafce34463e8e77756fdb6fc10f343359b50f8ec5a4a847374e.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Expand Up @@ -38,7 +38,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "b90974d5f9d943ad75f529ba0b8529aa1c43cbe4d63d4e0f89894d5fdcab56f9.zip"
"S3Key": "955124673880e20bd4e41d523bef58eb74503a0f574604d9ef9a6bd2c84336d6.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Expand Up @@ -828,7 +828,10 @@ var CustomResourceHandler = class {
hostname: parsedUrl.hostname,
path: parsedUrl.path,
method: "PUT",
headers: { "content-type": "", "content-length": responseBody.length }
headers: {
"content-type": "",
"content-length": Buffer.byteLength(responseBody, "utf8")
}
};
return new Promise((resolve, reject) => {
try {
Expand Down Expand Up @@ -983,7 +986,7 @@ function decodeCall(call) {
try {
const parsed = JSON.parse(call);
return parsed;
} catch (e) {
} catch {
return call;
}
}
Expand Down

0 comments on commit a8e9370

Please sign in to comment.