aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

📊Tracking: upgrade to Node 20

Open evgenyka opened this issue 3 years ago • 9 comments

Overview (updated 1/30/25)

Node 18, which is currently in its Active LTS phase, is slated to reach its End of Life on 2025-04-30, as indicated on https://nodejs.dev/en/about/releases/. Our aim is to provide CDK users with sufficient preparation time to update their CDK code to the latest LTS Node version (Node 20) before it becomes unsupported for deployed resources such as Lambda and Custom Resources.

Node 20 and 22 are available in CDK but are not the default for Lambda as not every region yet supports them, however it is available in Commercial, China and Gov Cloud regions. We recommend you use an explicit Node version such as NODEJS_22_X (rather than NODEJS_LATEST). The default NODEJS_LATEST will be updated once all regions support Node 20 (or 22).

For custom constructs the regional defaults for custom constructs in Commercial are now Node 20. The regional defaults for custom constructs in China and Gov Cloud regions have been updated to Node 20 and will be in the next release (expected 2/5/25)

Link to the service’s CDK Construct Library API reference page.

N/A

Maturity: CloudFormation Resources Only

Stable

Implementation

TBD

Issue list

  • aws/aws-cdk/issues/28125
  • [ ]

evgenyka avatar Sep 04 '23 16:09 evgenyka

Update around preview of AWS Lambda (Node 20 Support)

  • https://github.com/aws/aws-lambda-base-images/issues/91#issuecomment-1737694321
  • https://docs.aws.amazon.com/linux/al2023/ug/minimal-container.html

estrudels avatar Oct 16 '23 19:10 estrudels

Any progress? Slated completion is less than 2 weeks away.

haata avatar Oct 21 '24 15:10 haata

There are 2 issues in consideration here.

  1. CDK Custom resources using NodeJs as managed runtime for Lambda function. Customers cannot change or override the nodejs version for these custom resources. To mitigate this CDK released a region-awareness feature in v2.146.0 on 6/13. Due to this feature, the custom resources will use the lambda managed runtime available in your region. You should be able to see nodejs20 being used in commercial regions.
  • implement node runtime region awareness for cdk vended custom resources (#30108) (69c5dde)
  1. Variable nodejs_latest in (aws-cdk-lib/aws-lambda/lib/runtime.js). Customers can use the nodejs version of their choice instead of depending on this variable. This will be upgraded as we work on resolving a lambda runtime support dependency. Lambda runtime support timelines for the nodejs versions can be found in this doc

QuantumNeuralCoder avatar Oct 29 '24 05:10 QuantumNeuralCoder

Just to clarify further on previous, Node 20 and 22 are available in CDK but are not the default as not every region yet supports them.

e.g. Node 20 and 22 are supported for Lambda https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L113 but not the default https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L119

For custom constructs this PR was just merged to update defaults for custom constructs for a few more regions which now have Node 20 and will be in the next release. #33112

SimonCMoore avatar Jan 29 '25 20:01 SimonCMoore

What is the timeline to update the default Node version for the remaining regions?

timothy-baker avatar Apr 28 '25 16:04 timothy-baker

Custom resource default node runtime is now upgraded to node22 for all regions except isolated regions. This is available from CDK v2.197.0.

We continue to recommend customers do not use NODEJS_LATEST, for two reasons.

  1. While it may look like it means the latest node version, it actually means latest node available in all regions i.e. the lowest common denominator. Currently Node 18.
  2. Customers may be surprised when it is changed and may find their application needs changes to work on newer node versions. It is likely we will go straight from Node 18 to Node 22 once the isolated regions are updated Node 22 will become available at the same time as Node 20.
    Customers should use a specific node version for their lambdas such as NODEJS_22_X and plan to change this annually.

SimonCMoore avatar May 22 '25 16:05 SimonCMoore

I confess, I don't completely understand what's going on here. But I think this is the right place to post my question - apologies if not. Appreciate any pointers in the right direction.

I have a cdk app that when deployed the cdk framework itself creates a custom lambda resource that I have no control over. It's called MyAppName-CustomVpcRestrictDefaultSGCust-RandomString. It's a nodejs 18.x lambda.

My question is, how do I tell cdk to update the function to a more recent nodejs version?

region: us-west-2 the stack was first created on 2024-09-06 (I don't know what cdk version was used to create it)

I just upgraded to cdk 2.1017.1 and re-boostrapped and redeployed the app. No change to the lambda function's node version.

cdk synth shows the function definition in the yaml:

Image

Thanks

tonykgill avatar Jun 03 '25 05:06 tonykgill

Hi there, any update on this? We are fast approaching EOL for Node18, and any additional contexts we pull into our CDK project (e.g. @aws-cdk/aws-ec2:restrictDefaultSecurityGroup) are still stuck on that runtime.

ohookins avatar Aug 18 '25 01:08 ohookins

Hi, are there any updates, as other comments have mentioned we are approaching EOL for Node18 and my team would like to find an alternative to manually updating the node version (eg using LATEST if possible)

tsamiran avatar Sep 02 '25 22:09 tsamiran