aws-cdk
aws-cdk copied to clipboard
aws-cdk-lib: NODEJS_LATEST still points to nodejs18.x
Describe the bug
NODEJS_LATEST points to nodejs18.x even though nodejs20.x is available.
Not exactly sure if this should be considered a bug or a feature request?
I tried searching for any information regarding if the NODEJS_LATEST value change should be delayed because of some reason but couldn't find anything. Tried to ask about it here as well #28046, but haven't received any response there yet.
Expected Behavior
NODEJS_LATEST should return nodejs20.x
Current Behavior
NODEJS_LATEST returns nodejs18.x
This is where you can find the code: aws-cdk-lib/aws-lambda/lib/runtime.js
/**
* The latest NodeJS version currently available
*/
public static readonly NODEJS_LATEST = new Runtime('nodejs18.x', RuntimeFamily.NODEJS, { supportsInlineCode: true, isVariable: true });
Reproduction Steps
Just use the NODEJS_LATEST
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.110.1 (build 0d37f0d)
Framework Version
No response
Node.js Version
v20.9.0
OS
macOS
Language
TypeScript
Language Version
TypeScript v5.2.2
Other information
No response
Hi @MunchyYDL , Thnaks for reaching out. There is already work being done on upgrading the lambda runtime to NodeJS20 as the latest. It is being tracked here.
HI @khushail, thanks for the information, I will close my own attempts to fix this then, and leave it to you guys! 👍
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Reopening this because #27003 tracks CDK's transition from node18 to node20 in our underlying custom resources. This ticket tracks NODEJS_LATEST's move to node20, which will happen when the runtime exists in all regions.
Sorry, I thought you meant that there were other issues tracking this, I just wanted to clean up after myself.
And oh, do you have any more information about when nodejs20.x will be available in all regions, as my impressions from this article: Node.js 20.x runtime now available in AWS Lambda, was that it was available everywhere. 🤔
Or do you know where I can find more information about it?
That was actually some of my initial concerns, that I couldn't find any rules about if NODEJS_LATEST was supposed to still point to nodejs18.x or not.
@kaizencc Is this still on your radar? Also, I can't find any info that Node 20 is only available in certain regions (e.g. https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html, or https://aws.amazon.com/blogs/compute/node-js-20-x-runtime-now-available-in-aws-lambda/). Can you confirm that this is still the case, and maybe point me to a source?
Hey @MunchyYDL and @unstubbable, this blog post is where I see a reference to Node 20 not being available in all regions.
Thank you for bringing this issue up, and it is on our radar. We have some ideas on making NODEJS_LATEST represent the latest version rather than the "latest available in all regions". I think it would be better for my mental model of what the variable does, but let me know your thoughts! And we will update you with what decisions we make.
Hey @MunchyYDL and @unstubbable, this blog post is where I see a reference to Node 20 not being available in all regions.
Thank you for bringing this issue up, and it is on our radar. We have some ideas on making
NODEJS_LATESTrepresent the latest version rather than the "latest available in all regions". I think it would be better for my mental model of what the variable does, but let me know your thoughts! And we will update you with what decisions we make.
Selfishly, I'd want NODEJS_LATEST to always point to the latest runtime available in most regions, especially not including GovCloud or China. That said, I could see the broad usefulness of the variable to ensure random Lambda functions, like custom resources, that don't get updated much, are always on at least a supported version.
Given that, I might suggest a new variable: NODEJS_LATEST_GLOBAL that is available for all regions and NODEJS_LATEST that is the most commonly available latest. Alternatively, you could create a variable specially for not 100% available latest, if you're trying to prevent a breaking change. I just can't think of what that would be called off the top of my head. Maybe NODEJS_BLEEDING_EDGE? 😏
@automartin5000 I'm working on a PR that adds region awareness for node runtimes to our custom resources. I think it would make sense to point NODEJS_LATEST at this as well. We will be maintaining a fact table that keeps track of the latest node runtime available based on partition.
The nodejs20.x runtime is now (since 2024-09-23) available in the gov cloud: https://aws.amazon.com/about-aws/whats-new/2024/09/aws-lambda-linux-2023-runtimes-govcloud-regions/
Found no public information about the china regions :shrug:
Region awareness for (node) runtimes would be great though.
Just to clarify further, Node 20 and 22 are available in CDK but are not the default as not every region yet supports them, all commercial, china and gov cloud are now supported, so this only impacts a few.
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 (china and gov cloud) which now have Node 20 and will be in the next release. https://github.com/aws/aws-cdk/pull/33112
It's now 2025 April. Node18 is no longer in maintenance: https://nodejs.org/en/about/previous-releases
https://github.com/aws/aws-cdk/blob/v2.188.0/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L119 still has LATEST pointing at node18.
And yes, you can set the feature flag, but guys... please move this to at least node20.
edit: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md#aws-cdkaws-lambda-nodejsuselatestruntimeversion
Continuing to track. Unfortunately Node 18 is still the most recent version available in ALL regions. However as previously documented customers can explicitly use Node 20 and 22 for their Lambdas and custom resources will use Node 20 in all commercial regions.
Unfortunately, this has come in to conflict with the deprecation of 18. We have received notice from AWS for each of our accounts warning us about end of support. I can appreciate that the docs are clear that NODEJS_LATEST is going to yield the latest across all regions. I can also appreciate that I could work around this implementation by pinning specific versions of Node. That said, my purpose in using this is to avoid the chore of monitoring these things and am comforted that any issues caused by a change would be caught during the validation of our development environments.
My default expectation without having given it a lot of thought was that it would update as the actively supported version of Node evolved to automatically keep us ignoring these details and focused on our company. Is there an alternative that will behave in a region specific manner or that will behavior more in accordance with my default expectations and desired behavior?
@erikerikson you probably want to replace all instances of NODEJS_LATEST
with determineLatestRuntime(). It's a bit of a developer experience
disaster.
On Wed, Apr 30, 2025 at 2:52 PM Erik Erikson @.***> wrote:
erikerikson left a comment (aws/aws-cdk#28125) https://github.com/aws/aws-cdk/issues/28125#issuecomment-2843395510
Unfortunately, this has come in to conflict with the deprecation of 18. We have received notice from AWS for each of our accounts warning us about end of support. I can appreciate that the docs are clear that NODEJS_LATEST is going to yield the latest across all regions. I can also appreciate that I could work around this implementation by pinning specific versions of Node. That said, my purpose in using this is to avoid the chore of monitoring these things and am comforted that any issues caused by a change would be caught during the validation of our development environments.
My default expectation without having given it a lot of thought was that it would update as the actively supported version of Node evolved to automatically keep us ignoring these details and focused out our company. Is there an alternative that will behave in a region specific manner or that will behavior more in accordance with my default expectations and desired behavior?
— Reply to this email directly, view it on GitHub https://github.com/aws/aws-cdk/issues/28125#issuecomment-2843395510, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADM2RGB422FHSDBY5AQOUL24FAZBAVCNFSM6AAAAAA7YN4ROKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNBTGM4TKNJRGA . You are receiving this because you commented.Message ID: @.***>
-- MiniLockID: uX4VrN5FvyFxFCxgTksGxJqvKa16iBhqseYxxA1UkZVJw GPG: 773A 6BDD 71CE 0AB8 0F5A 1176 8679 A114 FB1A 69BD
Thanks @ahammond that helped me find determineLatestNodeRuntime
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.
- 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.
- 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 This is great progress!!!
Is NODEJS_LATEST formally @deprecated? It sounds like it should be.
Does determineLatestNodeRuntime() return node22 yet?
Hi all, in PR 35412 we added logic that will make sure NODEJE_LATEST works in sync with determineLatestNodeRuntime so it will be aware of the region you are deploying your stack and adjust the Node Version accordingly.
Closing this one as that PR resolved this issue.
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.