From 559c8fc5f8a16b7494d419e991d301a684f0996e Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Mon, 18 Nov 2024 12:40:38 +0100 Subject: [PATCH 1/3] chore: migrate dev environment to nodejs22 --- .devcontainer/devcontainer.json | 5 +++-- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .github/workflows/make-release.yml | 2 +- .github/workflows/make-version.yml | 2 +- .github/workflows/publish-package.yml | 2 +- .github/workflows/publish_layer.yml | 2 +- .../reusable-run-linting-check-and-unit-tests.yml | 12 ++++++------ .github/workflows/reusable_deploy_layer_stack.yml | 2 +- .github/workflows/reusable_publish_docs.yml | 2 +- .github/workflows/run-e2e-tests.yml | 6 +++--- .gitpod.Dockerfile | 4 ++-- .nvmrc | 2 +- docs/contributing/setup.md | 2 +- docs/contributing/testing.md | 2 +- docs/core/logger.md | 2 +- docs/core/metrics.md | 2 +- docs/core/tracer.md | 6 +++--- docs/index.md | 6 +++--- docs/upgrade.md | 4 ++-- examples/app/template.yaml | 2 +- examples/snippets/batch/templates/sam/dynamodb.yaml | 2 +- examples/snippets/batch/templates/sam/kinesis.yaml | 2 +- examples/snippets/batch/templates/sam/sqs.yaml | 2 +- .../snippets/idempotency/templates/tableSam.yaml | 2 +- layers/package.json | 1 + packages/batch/package.json | 1 + packages/event-handler/package.json | 1 + packages/idempotency/package.json | 1 + packages/logger/package.json | 1 + packages/metrics/package.json | 1 + packages/parameters/package.json | 1 + packages/parser/package.json | 1 + packages/testing/src/helpers.ts | 3 ++- packages/testing/src/resources/TestNodejsFunction.ts | 10 +++++++++- packages/tracer/package.json | 1 + 35 files changed, 59 insertions(+), 39 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8df8b4139e..e34e3ed22c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,14 +8,15 @@ // Append -bullseye or -buster to pin to an OS version. // Use -bullseye variants on local arm64/Apple Silicon. "args": { - "VARIANT": "20-bullseye" + "VARIANT": "22-bullseye" } }, "customizations": { // Add the ids of extensions you want installed when the container is created. "extensions": [ "biomejs.biome", - "firsttris.vscode-jest-runner" + "firsttris.vscode-jest-runner", + "vitest.explorer" ], "vscode": { "git.enableCommitSigning": true diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 515ae389cd..377669bed2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -67,6 +67,7 @@ body: attributes: label: AWS Lambda function runtime options: + - 22.x - 20.x - 18.x validations: diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml index e2e3e74874..4f8492cd28 100644 --- a/.github/workflows/make-release.yml +++ b/.github/workflows/make-release.yml @@ -51,7 +51,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: "20" + node-version: "22" cache: "npm" - name: Setup auth tokens run: | diff --git a/.github/workflows/make-version.yml b/.github/workflows/make-version.yml index 28988d3005..bde99f3604 100644 --- a/.github/workflows/make-version.yml +++ b/.github/workflows/make-version.yml @@ -25,7 +25,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: "20" + node-version: "22" cache: "npm" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 9a3ea059fa..65c19daa72 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -41,7 +41,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: "20" + node-version: "22" cache: "npm" - name: Setup auth tokens run: | diff --git a/.github/workflows/publish_layer.yml b/.github/workflows/publish_layer.yml index b1abff75be..e10bb7fd53 100644 --- a/.github/workflows/publish_layer.yml +++ b/.github/workflows/publish_layer.yml @@ -37,7 +37,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: "20" + node-version: "22" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 - name: CDK build diff --git a/.github/workflows/reusable-run-linting-check-and-unit-tests.yml b/.github/workflows/reusable-run-linting-check-and-unit-tests.yml index c34c2fd01e..ad1ce5177b 100644 --- a/.github/workflows/reusable-run-linting-check-and-unit-tests.yml +++ b/.github/workflows/reusable-run-linting-check-and-unit-tests.yml @@ -39,7 +39,7 @@ jobs: NODE_ENV: dev strategy: matrix: - version: [18, 20] + version: [18, 20, 22] workspace: [ "packages/batch", "packages/commons", @@ -76,7 +76,7 @@ jobs: NODE_ENV: dev strategy: matrix: - version: [18, 20] + version: [18, 20, 22] fail-fast: false steps: - name: Checkout code @@ -113,7 +113,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 20 + node-version: 22 cache: "npm" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 @@ -131,7 +131,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 20 + node-version: 22 cache: "npm" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 @@ -149,7 +149,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 20 + node-version: 22 cache: "npm" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 @@ -165,7 +165,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 20 + node-version: 22 cache: "npm" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 diff --git a/.github/workflows/reusable_deploy_layer_stack.yml b/.github/workflows/reusable_deploy_layer_stack.yml index 85f9d88464..a7444e52e2 100644 --- a/.github/workflows/reusable_deploy_layer_stack.yml +++ b/.github/workflows/reusable_deploy_layer_stack.yml @@ -74,7 +74,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: "20" + node-version: "22" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 - name: Download artifact diff --git a/.github/workflows/reusable_publish_docs.yml b/.github/workflows/reusable_publish_docs.yml index ffd6494b7b..fa84e14722 100644 --- a/.github/workflows/reusable_publish_docs.yml +++ b/.github/workflows/reusable_publish_docs.yml @@ -54,7 +54,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: "20" + node-version: "22" cache: "npm" - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 5f3f70b842..642f23a88c 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -32,7 +32,7 @@ jobs: packages/parameters, packages/idempotency, ] - version: [18, 20] + version: [18, 20, 22] arch: [x86_64, arm64] fail-fast: false steps: @@ -57,11 +57,11 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: '20' + node-version: '22' - name: Setup dependencies uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872 with: - nodeVersion: '20' + nodeVersion: '22' - name: Setup AWS credentials uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 with: diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index bee8186bd0..45a02118ba 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -1,5 +1,5 @@ -# See gitpod image here: https://hub.docker.com/layers/gitpod/workspace-base/latest -FROM gitpod/workspace-base@sha256:d69d08a0e1fa62b6d8db9e7ffe63dc21a58f0242946d945d776a819aec652130 +# See gitpod image here: https://hub.docker.com/r/gitpod/workspace-base +FROM gitpod/workspace-base@sha256-f08b7c4d5caf9e9a570deb49bf9987d4f725b7d1320dc2e948f795635f441747 USER gitpod diff --git a/.nvmrc b/.nvmrc index 9de2256827..deed13c016 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -lts/iron +lts/jod diff --git a/docs/contributing/setup.md b/docs/contributing/setup.md index de4c8416d7..68bcf2cba6 100644 --- a/docs/contributing/setup.md +++ b/docs/contributing/setup.md @@ -25,7 +25,7 @@ graph LR Unless you're using the pre-configured Cloud environment, you'll need the following installed: * [GitHub account](https://github.com/join){target="_blank" rel="nofollow"}. You'll need to be able to fork, clone, and contribute via pull request. -* [Node.js 20.x](https://nodejs.org/download/release/latest-v20.x/){target="_blank" rel="nofollow"}. The repository contains an `.nvmrc` file, so if you use tools like [nvm](https://github.com/nvm-sh/nvm#nvmrc), [fnm](https://github.com/Schniz/fnm) you can switch version quickly. +* [Node.js 22.x](https://nodejs.org/download/release/latest-v22.x/){target="_blank" rel="nofollow"}. The repository contains an `.nvmrc` file, so if you use tools like [nvm](https://github.com/nvm-sh/nvm#nvmrc), [fnm](https://github.com/Schniz/fnm) you can switch version quickly. * [npm 10.x](https://www.npmjs.com/). We use it to install dependencies and manage the workspaces. * [Docker](https://docs.docker.com/engine/install/){target="_blank" rel="nofollow"}. We use it to run documentation, and non-JavaScript tooling. * [Fork the repository](https://github.com/aws-powertools/powertools-lambda-typescript/fork). You'll work against your fork of this repository. diff --git a/docs/contributing/testing.md b/docs/contributing/testing.md index 8fd9c09ed3..f17841ab94 100644 --- a/docs/contributing/testing.md +++ b/docs/contributing/testing.md @@ -85,7 +85,7 @@ To run integration tests you'll need to set up an AWS account and obtain credent * `npm test:e2e -ws` to run all the integration tests for all the modules sequentially * `test:e2e:parallel` to run all the integration tests for all the modules in parallel * `npm test:e2e -w packages/metrics` to run all the integration tests for the `metrics` module -* `npm run test:e2e:nodejs20x -w packages/metrics` to run all the integration tests for the `metrics` module using the `nodejs20x` runtime +* `npm run test:e2e:nodejs22x -w packages/metrics` to run all the integration tests for the `metrics` module using the `nodejs22x` runtime The tests will deploy the necessary AWS resources using AWS CDK, and will run the Lambda functions using the AWS SDK. After that, the tests will verify the Lambda functions behave as expected by checking logs, metrics, traces, and other resources as needed. Finally, the tests will destroy all the AWS resources created at the beginning. diff --git a/docs/core/logger.md b/docs/core/logger.md index 3e116df7b6..ba32a8a86b 100644 --- a/docs/core/logger.md +++ b/docs/core/logger.md @@ -70,7 +70,7 @@ Check API docs to learn more about [Logger constructor options](https://docs.pow ShoppingCartApiFunction: Type: AWS::Serverless::Function Properties: - Runtime: nodejs20.x + Runtime: nodejs22.x Environment: Variables: POWERTOOLS_LOG_LEVEL: WARN diff --git a/docs/core/metrics.md b/docs/core/metrics.md index 30480520ca..9235a1f250 100644 --- a/docs/core/metrics.md +++ b/docs/core/metrics.md @@ -91,7 +91,7 @@ The `Metrics` utility is instantiated outside of the Lambda handler. In doing th HelloWorldFunction: Type: AWS::Serverless::Function Properties: - Runtime: nodejs20.x + Runtime: nodejs22.x Environment: Variables: POWERTOOLS_SERVICE_NAME: orders diff --git a/docs/core/tracer.md b/docs/core/tracer.md index 1629857ab7..8c3977deda 100644 --- a/docs/core/tracer.md +++ b/docs/core/tracer.md @@ -63,7 +63,7 @@ To use it in an ESM project, you can instruct your bundler to use the `require` super(scope, id, props); const handler = new NodejsFunction(this, 'helloWorldFunction', { - runtime: Runtime.NODEJS_20_X, + runtime: Runtime.NODEJS_22_X, handler: 'handler', entry: 'src/index.ts', bundling: { @@ -90,7 +90,7 @@ To use it in an ESM project, you can instruct your bundler to use the `require` HelloWorldFunction: Type: AWS::Serverless::Function Properties: - Runtime: nodejs20.x + Runtime: nodejs22.x Handler: src/index.handler Metadata: BuildMethod: esbuild @@ -140,7 +140,7 @@ The `Tracer` utility is instantiated outside of the Lambda handler. In doing thi HelloWorldFunction: Type: AWS::Serverless::Function Properties: - Runtime: nodejs20.x + Runtime: nodejs22.x Tracing: Active Environment: Variables: diff --git a/docs/index.md b/docs/index.md index 609977ff7a..e93f8045e7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -93,7 +93,7 @@ You can use Powertools for AWS Lambda (TypeScript) by installing it with your fa ); new Function(this, 'Function', { - runtime: Runtime.NODEJS_20_X, + runtime: Runtime.NODEJS_22_X, // Add the Layer to a Lambda function layers: [powertoolsLayer], code: Code.fromInline(`...`), @@ -189,7 +189,7 @@ You can use Powertools for AWS Lambda (TypeScript) by installing it with your fa function_name = "lambda_function_name" role = ... handler = "index.handler" - runtime = "nodejs20.x" + runtime = "nodejs22.x" layers = ["arn:aws:lambda:{aws::region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:15"] source_code_hash = filebase64sha256("lambda_function_payload.zip") } @@ -214,7 +214,7 @@ You can use Powertools for AWS Lambda (TypeScript) by installing it with your fa tracingConfig: { mode: 'Active' }, - runtime: aws.lambda.Runtime.NodeJS20dX, + runtime: aws.lambda.Runtime.NodeJS22dX, handler: 'index.handler', role: role.arn, architectures: ['x86_64'] diff --git a/docs/upgrade.md b/docs/upgrade.md index f37bd461b4..d8e83b514f 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -78,7 +78,7 @@ Here is an example using `esbuild` bundler. super(scope, id, props); const handler = new NodejsFunction(this, 'helloWorldFunction', { - runtime: Runtime.NODEJS_20_X, + runtime: Runtime.NODEJS_22_X, handler: 'handler', entry: 'src/index.ts', bundling: { @@ -105,7 +105,7 @@ Here is an example using `esbuild` bundler. HelloWorldFunction: Type: AWS::Serverless::Function Properties: - Runtime: nodejs20.x + Runtime: nodejs22.x Handler: src/index.handler Metadata: BuildMethod: esbuild diff --git a/examples/app/template.yaml b/examples/app/template.yaml index bac8f32b7c..e9f0c3a522 100644 --- a/examples/app/template.yaml +++ b/examples/app/template.yaml @@ -10,7 +10,7 @@ Transform: AWS::Serverless-2016-10-31 # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy-globals.html Globals: Function: - Runtime: nodejs20.x + Runtime: nodejs22.x Tracing: Active Architectures: - arm64 diff --git a/examples/snippets/batch/templates/sam/dynamodb.yaml b/examples/snippets/batch/templates/sam/dynamodb.yaml index 83dc648054..16164f1ad5 100644 --- a/examples/snippets/batch/templates/sam/dynamodb.yaml +++ b/examples/snippets/batch/templates/sam/dynamodb.yaml @@ -6,7 +6,7 @@ Globals: Function: Timeout: 5 MemorySize: 256 - Runtime: nodejs20.x + Runtime: nodejs22.x Tracing: Active Environment: Variables: diff --git a/examples/snippets/batch/templates/sam/kinesis.yaml b/examples/snippets/batch/templates/sam/kinesis.yaml index 3de5232790..55db822e90 100644 --- a/examples/snippets/batch/templates/sam/kinesis.yaml +++ b/examples/snippets/batch/templates/sam/kinesis.yaml @@ -6,7 +6,7 @@ Globals: Function: Timeout: 5 MemorySize: 256 - Runtime: nodejs20.x + Runtime: nodejs22.x Tracing: Active Environment: Variables: diff --git a/examples/snippets/batch/templates/sam/sqs.yaml b/examples/snippets/batch/templates/sam/sqs.yaml index 77ce058c94..484b7c937d 100644 --- a/examples/snippets/batch/templates/sam/sqs.yaml +++ b/examples/snippets/batch/templates/sam/sqs.yaml @@ -6,7 +6,7 @@ Globals: Function: Timeout: 5 MemorySize: 256 - Runtime: nodejs20.x + Runtime: nodejs22.x Tracing: Active Environment: Variables: diff --git a/examples/snippets/idempotency/templates/tableSam.yaml b/examples/snippets/idempotency/templates/tableSam.yaml index ccd2078aee..9de5e226de 100644 --- a/examples/snippets/idempotency/templates/tableSam.yaml +++ b/examples/snippets/idempotency/templates/tableSam.yaml @@ -17,7 +17,7 @@ Resources: HelloWorldFunction: Type: AWS::Serverless::Function Properties: - Runtime: nodejs20.x + Runtime: nodejs22.x Handler: app.py Policies: - Statement: diff --git a/layers/package.json b/layers/package.json index efdfb34946..de336c53fc 100644 --- a/layers/package.json +++ b/layers/package.json @@ -13,6 +13,7 @@ "test:unit:types": "echo 'Not Implemented'", "test:e2e:nodejs18x": "echo 'Not Implemented'", "test:e2e:nodejs20x": "echo 'Not Implemented'", + "test:e2e:nodejs22x": "echo 'Not Implemented'", "test:e2e": "vitest --run tests/e2e", "build": "echo 'Not applicable, run `npx cdk synth` instead to build the stack'", "jest": "jest --detectOpenHandles", diff --git a/packages/batch/package.json b/packages/batch/package.json index d58b3668bb..4f85c67d6c 100644 --- a/packages/batch/package.json +++ b/packages/batch/package.json @@ -16,6 +16,7 @@ "test:unit:types": "echo 'Not Implemented'", "test:e2e:nodejs18x": "echo 'Not Implemented'", "test:e2e:nodejs20x": "echo 'Not Implemented'", + "test:e2e:nodejs22x": "echo 'Not Implemented'", "test:e2e": "echo 'Not Implemented'", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", diff --git a/packages/event-handler/package.json b/packages/event-handler/package.json index a3d8f9342a..8deff710f7 100644 --- a/packages/event-handler/package.json +++ b/packages/event-handler/package.json @@ -14,6 +14,7 @@ "test:unit:types": "echo 'Not Implemented'", "test:e2e:nodejs18x": "echo \"Not implemented\"", "test:e2e:nodejs20x": "echo \"Not implemented\"", + "test:e2e:nodejs22x": "echo \"Not implemented\"", "test:e2e": "echo \"Not implemented\"", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", diff --git a/packages/idempotency/package.json b/packages/idempotency/package.json index 383c878c83..2fff7ba17c 100644 --- a/packages/idempotency/package.json +++ b/packages/idempotency/package.json @@ -17,6 +17,7 @@ "test:unit:watch": "vitest tests/unit", "test:e2e:nodejs18x": "RUNTIME=nodejs18x vitest --run tests/e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x vitest --run tests/e2e", + "test:e2e:nodejs22x": "RUNTIME=nodejs22x vitest --run tests/e2e", "test:e2e": "vitest --run tests/e2e", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", diff --git a/packages/logger/package.json b/packages/logger/package.json index 5800d75e23..65051db14d 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -17,6 +17,7 @@ "test:unit:watch": "vitest tests/unit", "test:e2e:nodejs18x": "RUNTIME=nodejs18x vitest --run tests/e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x vitest --run tests/e2e", + "test:e2e:nodejs22x": "RUNTIME=nodejs22x vitest --run tests/e2e", "test:e2e": "vitest --run tests/e2e", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", diff --git a/packages/metrics/package.json b/packages/metrics/package.json index 9a4c8f4e00..7d483d8c97 100644 --- a/packages/metrics/package.json +++ b/packages/metrics/package.json @@ -14,6 +14,7 @@ "test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose", "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x jest --group=e2e", + "test:e2e:nodejs22x": "RUNTIME=nodejs22x jest --group=e2e", "test:e2e": "jest --group=e2e", "watch": "jest --group=unit --watch ", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", diff --git a/packages/parameters/package.json b/packages/parameters/package.json index c10a926743..cb841d2584 100644 --- a/packages/parameters/package.json +++ b/packages/parameters/package.json @@ -17,6 +17,7 @@ "test:unit:watch": "vitest tests/unit", "test:e2e:nodejs18x": "RUNTIME=nodejs18x vitest --run tests/e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x vitest --run tests/e2e", + "test:e2e:nodejs22x": "RUNTIME=nodejs22x vitest --run tests/e2e", "test:e2e": "vitest --run tests/e2e", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", diff --git a/packages/parser/package.json b/packages/parser/package.json index ad30a4805d..037d991e3e 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -17,6 +17,7 @@ "test:unit:watch": "vitest tests/unit", "test:e2e:nodejs18x": "echo 'Not implemented'", "test:e2e:nodejs20x": "echo 'Not implemented'", + "test:e2e:nodejs22x": "echo 'Not implemented'", "test:e2e": "echo 'Not implemented'", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", diff --git a/packages/testing/src/helpers.ts b/packages/testing/src/helpers.ts index 5d7891dfd6..f0a755b6c5 100644 --- a/packages/testing/src/helpers.ts +++ b/packages/testing/src/helpers.ts @@ -8,7 +8,8 @@ import { const isValidRuntimeKey = ( runtime: string -): runtime is keyof typeof TEST_RUNTIMES => runtime in TEST_RUNTIMES; +): runtime is keyof typeof TEST_RUNTIMES => + runtime in TEST_RUNTIMES || runtime === 'nodejs22x'; const getRuntimeKey = (): keyof typeof TEST_RUNTIMES => { const runtime: string = process.env.RUNTIME || defaultRuntime; diff --git a/packages/testing/src/resources/TestNodejsFunction.ts b/packages/testing/src/resources/TestNodejsFunction.ts index b1123adaa9..354049bb29 100644 --- a/packages/testing/src/resources/TestNodejsFunction.ts +++ b/packages/testing/src/resources/TestNodejsFunction.ts @@ -1,5 +1,5 @@ import { randomUUID } from 'node:crypto'; -import { CfnOutput, Duration } from 'aws-cdk-lib'; +import { CfnOutput, type CfnResource, Duration } from 'aws-cdk-lib'; import { Tracing } from 'aws-cdk-lib/aws-lambda'; import { NodejsFunction, OutputFormat } from 'aws-cdk-lib/aws-lambda-nodejs'; import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs'; @@ -56,6 +56,14 @@ class TestNodejsFunction extends NodejsFunction { logGroup, }); + // @ts-ignore + if (getRuntimeKey() === 'nodejs22x') { + (this.node.defaultChild as CfnResource).addPropertyOverride( + 'Runtime', + 'nodejs22.x' + ); + } + new CfnOutput(this, extraProps.nameSuffix, { value: this.functionName, }); diff --git a/packages/tracer/package.json b/packages/tracer/package.json index d218ea228e..f962f54266 100644 --- a/packages/tracer/package.json +++ b/packages/tracer/package.json @@ -17,6 +17,7 @@ "test:unit:watch": "vitest tests/unit", "test:e2e:nodejs18x": "RUNTIME=nodejs18x vitest --run tests/e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x vitest --run tests/e2e", + "test:e2e:nodejs22x": "RUNTIME=nodejs22x vitest --run tests/e2e", "test:e2e": "vitest --run tests/e2e", "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", From ef808569dcd259b82e5e06f16819b21b45ccded2 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 20 Nov 2024 18:27:02 +0100 Subject: [PATCH 2/3] chore: update layers & e2e to latest cdk --- layers/src/layer-publisher-stack.ts | 8 ++++++-- packages/testing/src/constants.ts | 5 +++-- packages/testing/src/resources/TestNodejsFunction.ts | 8 -------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/layers/src/layer-publisher-stack.ts b/layers/src/layer-publisher-stack.ts index b5652d6e59..9bd7ddd3a8 100644 --- a/layers/src/layer-publisher-stack.ts +++ b/layers/src/layer-publisher-stack.ts @@ -36,14 +36,18 @@ export class LayerPublisherStack extends Stack { this.lambdaLayerVersion = new LayerVersion(this, 'LambdaPowertoolsLayer', { layerVersionName: props?.layerName, description: `Powertools for AWS Lambda (TypeScript) version ${powertoolsPackageVersion}`, - compatibleRuntimes: [Runtime.NODEJS_18_X, Runtime.NODEJS_20_X], + compatibleRuntimes: [ + Runtime.NODEJS_18_X, + Runtime.NODEJS_20_X, + Runtime.NODEJS_22_X, + ], license: 'MIT-0', // This is needed because the following regions do not support the compatibleArchitectures property #1400 // ...(![ 'eu-south-2', 'eu-central-2', 'ap-southeast-4' ].includes(Stack.of(this).region) ? { compatibleArchitectures: [Architecture.X86_64] } : {}), code: Code.fromAsset(resolve(__dirname), { bundling: { // This is here only because is required by CDK, however it is not used since the bundling is done locally - image: Runtime.NODEJS_20_X.bundlingImage, + image: Runtime.NODEJS_22_X.bundlingImage, // We need to run a command to generate a random UUID to force the bundling to run every time command: [`echo "${randomUUID()}"`], local: { diff --git a/packages/testing/src/constants.ts b/packages/testing/src/constants.ts index de3c862b9f..87122bcca8 100644 --- a/packages/testing/src/constants.ts +++ b/packages/testing/src/constants.ts @@ -3,14 +3,15 @@ import { Architecture, Runtime } from 'aws-cdk-lib/aws-lambda'; /** * The default AWS Lambda runtime to use when none is provided. */ -const defaultRuntime = 'nodejs20x'; +const defaultRuntime = 'nodejs22x'; /** * The AWS Lambda runtimes that are supported by the project. */ const TEST_RUNTIMES = { nodejs18x: Runtime.NODEJS_18_X, - [defaultRuntime]: Runtime.NODEJS_20_X, + nodejs20x: Runtime.NODEJS_20_X, + [defaultRuntime]: Runtime.NODEJS_22_X, } as const; /** diff --git a/packages/testing/src/resources/TestNodejsFunction.ts b/packages/testing/src/resources/TestNodejsFunction.ts index 354049bb29..01a383153f 100644 --- a/packages/testing/src/resources/TestNodejsFunction.ts +++ b/packages/testing/src/resources/TestNodejsFunction.ts @@ -56,14 +56,6 @@ class TestNodejsFunction extends NodejsFunction { logGroup, }); - // @ts-ignore - if (getRuntimeKey() === 'nodejs22x') { - (this.node.defaultChild as CfnResource).addPropertyOverride( - 'Runtime', - 'nodejs22.x' - ); - } - new CfnOutput(this, extraProps.nameSuffix, { value: this.functionName, }); From c1180987d4b141d12fa28d4caeb3b1ff282bd90a Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 20 Nov 2024 18:43:38 +0100 Subject: [PATCH 3/3] tests: update layer snapshot test --- layers/tests/unit/layer-publisher.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layers/tests/unit/layer-publisher.test.ts b/layers/tests/unit/layer-publisher.test.ts index fc20e88d06..83b92f3b7a 100644 --- a/layers/tests/unit/layer-publisher.test.ts +++ b/layers/tests/unit/layer-publisher.test.ts @@ -20,7 +20,7 @@ describe('Class: LayerPublisherStack', () => { // Assess template.resourceCountIs('AWS::Lambda::LayerVersion', 1); template.hasResourceProperties('AWS::Lambda::LayerVersion', { - CompatibleRuntimes: ['nodejs18.x', 'nodejs20.x'], + CompatibleRuntimes: ['nodejs18.x', 'nodejs20.x', 'nodejs22.x'], LicenseInfo: 'MIT-0', /* CompatibleArchitectures: [ 'x86_64',