Skip to content

Commit 5d38256

Browse files
committed
feat(maintenance): add support for nodejs20.x runtime (#1790)
* feat(maintenance): support nodejs20.x runtime * tests(metrics): fix object ordering in tests * build(testing): bump cdk * build(maintenance): revert aws-cdk-lib to support nodejs14 * tests(maintenance): set runtime with family * chore(docs): patch runtime in cdk * chore(docs): patch runtime in cdk * chore(maintenance): increment version in commons ahead of release
1 parent 9c47362 commit 5d38256

Some content is hidden

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

45 files changed

+216
-241
lines changed

Diff for: .devcontainer/Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/v0.212.0/containers/javascript-node/.devcontainer/base.Dockerfile
22
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
3-
ARG VARIANT="18-bullseye"
3+
ARG VARIANT="20-bullseye"
44
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
55

66
# This section to install additional OS packages.
77
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
88
&& apt-get -y install --no-install-recommends bash-completion
99

10+
# Install fnm to manage Node.js versions
11+
RUN curl -fsSL https://fnm.vercel.app/install | bash -s
12+
1013
RUN wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip \
1114
&& unzip aws-sam-cli-linux-x86_64.zip -d sam-installation \
1215
&& sudo ./sam-installation/install \

Diff for: .devcontainer/devcontainer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
// Append -bullseye or -buster to pin to an OS version.
99
// Use -bullseye variants on local arm64/Apple Silicon.
1010
"args": {
11-
"VARIANT": "18-bullseye"
11+
"VARIANT": "20-bullseye"
1212
}
1313
},
1414
"customizations": {
1515
// Add the ids of extensions you want installed when the container is created.
1616
"extensions": [
1717
"dbaeumer.vscode-eslint",
1818
"esbenp.prettier-vscode",
19-
"firsttris.vscode-jest-runner",
20-
"amazonwebservices.aws-toolkit-vscode"
19+
"firsttris.vscode-jest-runner"
2120
],
2221
"vscode": {
2322
"git.enableCommitSigning": true

Diff for: .github/actions/cached-node-modules/action.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: 'Cached Node Modules'
22
description: 'A simple action to cache node_modules or install them if they are not cached'
33
inputs:
4-
nodeVersion: # id of input
4+
nodeVersion: # id of input
55
description: 'Node.js version to use in the cache key'
6-
default: '18'
6+
default: '20'
77
build:
88
description: 'Whether to build the packages or not'
99
default: 'true'
@@ -15,6 +15,7 @@ runs:
1515
using: "composite"
1616
steps:
1717
- name: Install npm
18+
# We need to keep this npm version until we drop Node.js 16 support because Node.js 16 doesn't support npm 10
1819
run: npm i -g npm@next-9
1920
shell: bash
2021
- name: Cache node modules

Diff for: .github/workflows/make-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup NodeJS
2727
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
2828
with:
29-
node-version: "18"
29+
node-version: "20"
3030
cache: "npm"
3131
- name: Setup auth tokens
3232
run: |

Diff for: .github/workflows/make-v2-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup NodeJS
2222
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
2323
with:
24-
node-version: '18'
24+
node-version: '20'
2525
cache: 'npm'
2626
- name: Setup auth tokens
2727
run: |

Diff for: .github/workflows/publish_layer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Setup Node.js
4040
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
4141
with:
42-
node-version: "18"
42+
node-version: "20"
4343
- name: Setup dependencies
4444
uses: ./.github/actions/cached-node-modules
4545
- name: CDK build

Diff for: .github/workflows/reusable-publish-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Setup NodeJS
4848
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
4949
with:
50-
node-version: "18"
50+
node-version: "20"
5151
cache: "npm"
5252
- name: Setup dependencies
5353
uses: ./.github/actions/cached-node-modules

Diff for: .github/workflows/reusable-run-linting-check-and-unit-tests.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
NODE_ENV: dev
1111
strategy:
1212
matrix:
13-
version: [16, 18]
13+
version: [16, 18, 20]
1414
fail-fast: false
1515
steps:
1616
- name: Checkout code
@@ -45,8 +45,8 @@ jobs:
4545
- name: Setup NodeJS
4646
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
4747
with:
48-
node-version: 18
49-
cache: 'npm'
48+
node-version: 20
49+
cache: "npm"
5050
- name: Setup dependencies
5151
uses: ./.github/actions/cached-node-modules
5252
- name: Run linting
@@ -63,8 +63,8 @@ jobs:
6363
- name: Setup NodeJS
6464
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
6565
with:
66-
node-version: 18
67-
cache: 'npm'
66+
node-version: 20
67+
cache: "npm"
6868
- name: Setup dependencies
6969
uses: ./.github/actions/cached-node-modules
7070
- name: Run linting
@@ -81,8 +81,8 @@ jobs:
8181
- name: Setup NodeJS
8282
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
8383
with:
84-
node-version: 18
85-
cache: 'npm'
84+
node-version: 20
85+
cache: "npm"
8686
- name: Setup dependencies
8787
uses: ./.github/actions/cached-node-modules
8888
- name: Run linting

Diff for: .github/workflows/reusable_deploy_layer_stack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
- name: Setup Node.js
7272
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
7373
with:
74-
node-version: "18"
74+
node-version: "20"
7575
- name: Setup dependencies
7676
uses: ./.github/actions/cached-node-modules
7777
- name: Download artifact

Diff for: .github/workflows/run-e2e-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
packages/parameters,
2929
packages/idempotency,
3030
]
31-
version: [16, 18]
31+
version: [16, 18, 20]
3232
arch: [x86_64, arm64]
3333
fail-fast: false
3434
steps:
@@ -53,11 +53,11 @@ jobs:
5353
- name: Setup NodeJS
5454
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
5555
with:
56-
node-version: ${{ matrix.version }}
56+
node-version: '20'
5757
- name: Setup dependencies
5858
uses: ./.github/actions/cached-node-modules
5959
with:
60-
nodeVersion: ${{ matrix.version }}
60+
nodeVersion: '20'
6161
- name: Setup AWS credentials
6262
uses: aws-actions/configure-aws-credentials@04b98b3f9e85f563fb061be8751a0352327246b0 # v3.0.1
6363
with:

Diff for: .nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lts/hydrogen
1+
lts/iron

Diff for: docs/contributing/setup.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ graph LR
2323
Unless you're using the pre-configured Cloud environment, you'll need the following installed:
2424

2525
* [GitHub account](https://github.com/join){target="_blank" rel="nofollow"}. You'll need to be able to fork, clone, and contribute via pull request.
26-
* [Node.js 18.x](https://nodejs.org/download/release/latest-v18.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.
27-
* [npm 9.x](https://www.npmjs.com/). We use it to install dependencies and manage the workspaces.
26+
* [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.
27+
* [npm 10.x](https://www.npmjs.com/). We use it to install dependencies and manage the workspaces.
2828
* [Docker](https://docs.docker.com/engine/install/){target="_blank" rel="nofollow"}. We use it to run documentation, and non-JavaScript tooling.
2929
* [Fork the repository](https://github.com/aws-powertools/powertools-lambda-typescript/fork). You'll work against your fork of this repository.
3030

Diff for: docs/contributing/testing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ To run integration tests you'll need to set up an AWS account and obtain credent
8484
* `npm test:e2e -ws` to run all the integration tests for all the modules sequentially
8585
* `test:e2e:parallel` to run all the integration tests for all the modules in parallel
8686
* `npm test:e2e -w packages/metrics` to run all the integration tests for the `metrics` module
87-
* `npm run test:e2e:nodejs18x -w packages/metrics` to run all the integration tests for the `metrics` module using the `nodejs18x` runtime
87+
* `npm run test:e2e:nodejs20x -w packages/metrics` to run all the integration tests for the `metrics` module using the `nodejs20x` runtime
8888

8989
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.
9090

Diff for: docs/core/logger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ These settings will be used across all logs emitted:
6868
ShoppingCartApiFunction:
6969
Type: AWS::Serverless::Function
7070
Properties:
71-
Runtime: nodejs18.x
71+
Runtime: nodejs20.x
7272
Environment:
7373
Variables:
7474
LOG_LEVEL: WARN

Diff for: docs/core/metrics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The `Metrics` utility is instantiated outside of the Lambda handler. In doing th
8888
HelloWorldFunction:
8989
Type: AWS::Serverless::Function
9090
Properties:
91-
Runtime: nodejs16.x
91+
Runtime: nodejs20.x
9292
Environment:
9393
Variables:
9494
POWERTOOLS_SERVICE_NAME: orders

Diff for: docs/core/tracer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The `Tracer` utility is instantiated outside of the Lambda handler. In doing thi
7474
HelloWorldFunction:
7575
Type: AWS::Serverless::Function
7676
Properties:
77-
Runtime: nodejs18.x
77+
Runtime: nodejs20.x
7878
Tracing: Active
7979
Environment:
8080
Variables:

Diff for: docs/snippets/batch/templates/sam/dynamodb.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Globals:
66
Function:
77
Timeout: 5
88
MemorySize: 256
9-
Runtime: nodejs18.x
9+
Runtime: nodejs20.x
1010
Tracing: Active
1111
Environment:
1212
Variables:

Diff for: docs/snippets/batch/templates/sam/kinesis.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Globals:
66
Function:
77
Timeout: 5
88
MemorySize: 256
9-
Runtime: nodejs18.x
9+
Runtime: nodejs20.x
1010
Tracing: Active
1111
Environment:
1212
Variables:

Diff for: docs/snippets/batch/templates/sam/sqs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Globals:
66
Function:
77
Timeout: 5
88
MemorySize: 256
9-
Runtime: nodejs18.x
9+
Runtime: nodejs20.x
1010
Tracing: Active
1111
Environment:
1212
Variables:

Diff for: docs/snippets/idempotency/templates/tableCdk.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class IdempotencyStack extends Stack {
1818
});
1919

2020
const fnHandler = new NodejsFunction(this, 'helloWorldFunction', {
21-
runtime: Runtime.NODEJS_18_X,
21+
runtime: Runtime.NODEJS_20_X,
2222
handler: 'handler',
2323
entry: 'src/index.ts',
2424
environment: {

Diff for: docs/snippets/idempotency/templates/tableSam.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Resources:
1717
HelloWorldFunction:
1818
Type: AWS::Serverless::Function
1919
Properties:
20-
Runtime: python3.11
20+
Runtime: nodejs20.x
2121
Handler: app.py
2222
Policies:
2323
- Statement:

Diff for: docs/snippets/idempotency/templates/tableTerraform.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ resource "aws_dynamodb_table" "IdempotencyTable" {
2828
resource "aws_lambda_function" "IdempotencyFunction" {
2929
function_name = "IdempotencyFunction"
3030
role = aws_iam_role.IdempotencyFunctionRole.arn
31-
runtime = "nodejs18.x"
31+
runtime = "nodejs20.x"
3232
handler = "index.handler"
3333
filename = "lambda.zip"
3434
}

Diff for: docs/utilities/idempotency.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ While we support Amazon DynamoDB as a persistance layer out of the box, you need
6060

6161

6262
???+ note
63-
This utility supports **[AWS SDK for JavaScript v3](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/){target="_blank"} only**. If you are using the `nodejs18.x` runtime, the AWS SDK for JavaScript v3 is already installed and you can install only the utility.
63+
This utility supports **[AWS SDK for JavaScript v3](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/){target="_blank"} only**. If you are using the `nodejs18.x` runtime or newer, the AWS SDK for JavaScript v3 is already installed and you can install only the utility.
6464

6565

6666
### IAM Permissions

Diff for: docs/utilities/parameters.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Depending on the provider you want to use, install the library and the correspon
4444
```
4545

4646
???+ tip
47-
If you are using the `nodejs18.x` runtime, the AWS SDK for JavaScript v3 is already installed and you can install the utility only.
47+
If you are using the `nodejs18.x` runtime or newer, the AWS SDK for JavaScript v3 is already installed and you can install the utility only.
4848

4949
### IAM Permissions
5050

Diff for: examples/cdk/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@types/aws-lambda": "^8.10.121",
3636
"@types/jest": "^29.5.4",
3737
"@types/node": "20.6.1",
38-
"aws-cdk": "^2.96.1",
38+
"aws-cdk": "^2.107.0",
3939
"esbuild": "^0.19.3",
4040
"jest": "^29.7.0",
4141
"ts-jest": "^29.1.1",
@@ -44,7 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@middy/core": "^3.6.2",
47-
"aws-cdk-lib": "^2.96.1",
47+
"aws-cdk-lib": "^2.107.0",
4848
"constructs": "^10.2.70",
4949
"phin": "^3.7.0",
5050
"source-map-support": "^0.5.21"

Diff for: examples/cdk/src/example-stack.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { StringParameter } from 'aws-cdk-lib/aws-ssm';
1111
import { Construct } from 'constructs';
1212

1313
const commonProps: Partial<NodejsFunctionProps> = {
14-
runtime: Runtime.NODEJS_18_X,
14+
runtime: Runtime.NODEJS_20_X,
1515
tracing: Tracing.ACTIVE,
1616
timeout: Duration.seconds(30),
1717
logRetention: RetentionDays.ONE_DAY,
@@ -112,7 +112,7 @@ class UuidApi extends Construct {
112112
super(scope, id);
113113

114114
const uuidFn = new NodejsFunction(this, 'UuidFn', {
115-
runtime: Runtime.NODEJS_18_X,
115+
runtime: Runtime.NODEJS_20_X,
116116
entry: './functions/uuid.ts',
117117
});
118118

Diff for: examples/sam/template.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Parameters:
3131
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy-globals.html
3232
Globals:
3333
Function:
34-
Runtime: nodejs18.x
34+
Runtime: nodejs20.x
3535
Architectures:
3636
- x86_64
3737
MemorySize: 128

Diff for: layers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"dependencies": {
4242
"aws-cdk": "^2.96.1",
43-
"aws-cdk-lib": "^2.96.1",
43+
"aws-cdk-lib": "^2.107.0",
4444
"esbuild": "^0.19.3"
4545
}
4646
}

Diff for: layers/src/layer-publisher-stack.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ export class LayerPublisherStack extends Stack {
3636
this.lambdaLayerVersion = new LayerVersion(this, 'LambdaPowertoolsLayer', {
3737
layerVersionName: props?.layerName,
3838
description: `Powertools for AWS Lambda (TypeScript) version ${powertoolsPackageVersion}`,
39-
compatibleRuntimes: [Runtime.NODEJS_16_X, Runtime.NODEJS_18_X],
39+
compatibleRuntimes: [
40+
Runtime.NODEJS_16_X,
41+
Runtime.NODEJS_18_X,
42+
Runtime.NODEJS_20_X,
43+
],
4044
license: 'MIT-0',
4145
// This is needed because the following regions do not support the compatibleArchitectures property #1400
4246
// ...(![ 'eu-south-2', 'eu-central-2', 'ap-southeast-4' ].includes(Stack.of(this).region) ? { compatibleArchitectures: [Architecture.X86_64] } : {}),
4347
code: Code.fromAsset(resolve(__dirname), {
4448
bundling: {
4549
// This is here only because is required by CDK, however it is not used since the bundling is done locally
46-
image: Runtime.NODEJS_18_X.bundlingImage,
50+
image: Runtime.NODEJS_20_X.bundlingImage,
4751
// We need to run a command to generate a random UUID to force the bundling to run every time
4852
command: [`echo "${randomUUID()}"`],
4953
local: {

Diff for: layers/tests/unit/layer-publisher.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Class: LayerPublisherStack', () => {
2525
// Assess
2626
template.resourceCountIs('AWS::Lambda::LayerVersion', 1);
2727
template.hasResourceProperties('AWS::Lambda::LayerVersion', {
28-
CompatibleRuntimes: ['nodejs16.x', 'nodejs18.x'],
28+
CompatibleRuntimes: ['nodejs16.x', 'nodejs18.x', 'nodejs20.x'],
2929
LicenseInfo: 'MIT-0',
3030
/* CompatibleArchitectures: [
3131
'x86_64',

0 commit comments

Comments
 (0)