Skip to content

Commit

Permalink
chore: migrate dev environment to nodejs22 (#3327)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamorosi authored Nov 20, 2024
1 parent dffde6c commit 6733584
Show file tree
Hide file tree
Showing 38 changed files with 61 additions and 44 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ body:
attributes:
label: AWS Lambda function runtime
options:
- 22.x
- 20.x
- 18.x
validations:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_layer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/reusable-run-linting-check-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
NODE_ENV: dev
strategy:
matrix:
version: [18, 20]
version: [18, 20, 22]
workspace: [
"packages/batch",
"packages/commons",
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
NODE_ENV: dev
strategy:
matrix:
version: [18, 20]
version: [18, 20, 22]
fail-fast: false
steps:
- name: Checkout code
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_deploy_layer_stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
packages/parameters,
packages/idempotency,
]
version: [18, 20]
version: [18, 20, 22]
arch: [x86_64, arm64]
fail-fast: false
steps:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/iron
lts/jod
2 changes: 1 addition & 1 deletion docs/contributing/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/core/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/core/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/core/tracer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(`...`),
Expand Down Expand Up @@ -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")
}
Expand All @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions docs/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/app/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/batch/templates/sam/dynamodb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Globals:
Function:
Timeout: 5
MemorySize: 256
Runtime: nodejs20.x
Runtime: nodejs22.x
Tracing: Active
Environment:
Variables:
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/batch/templates/sam/kinesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Globals:
Function:
Timeout: 5
MemorySize: 256
Runtime: nodejs20.x
Runtime: nodejs22.x
Tracing: Active
Environment:
Variables:
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/batch/templates/sam/sqs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Globals:
Function:
Timeout: 5
MemorySize: 256
Runtime: nodejs20.x
Runtime: nodejs22.x
Tracing: Active
Environment:
Variables:
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/idempotency/templates/tableSam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs20.x
Runtime: nodejs22.x
Handler: app.py
Policies:
- Statement:
Expand Down
1 change: 1 addition & 0 deletions layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions layers/src/layer-publisher-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion layers/tests/unit/layer-publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions packages/batch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/event-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/idempotency/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 6733584

Please sign in to comment.