Skip to content

fix(lambda): use nodejs22.x as default runtime #34117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahammond
Copy link
Contributor

@ahammond ahammond commented Apr 11, 2025

  • Deprecate NODE_LATEST in favor of determineLatestNodeRuntime().
  • Fix misleading description of @aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion feature flag.
  • Mark nodejs18.x as deprecated (it's no longer in maintenance upstream, folks should upgrade)

Nodejs18 is no longer in maintenance: https://nodejs.org/en/about/previous-releases
and will be deprecated by AWS on 2025 September 1 https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

NODE_LATEST still points to v18:
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L119

I see that there's been an issue about this since 2023: #28125

The feature flag? @aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda-nodejs/lib/function.ts#L182
As written, gives you NODE_LATEST (v18) by default instead of v16.

The best practice seems to be to use determineLatestNodeRuntime()
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L414,
But even that can default to v18.

Issue # (if applicable)

Closes #28125

Reason for this change

I just wasted a bunch of time assuming that NODEJS_LATEST meant what it implied.
More time assuming that "useLatestRuntimeVersion" did what it said.

Description of changes

See above.

Describe any new or updated permissions being added

None.

Description of how you validated changes

Existing tests updated with new defaults.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

- Deprecate NODE_LATEST in favor of determineLatestNodeRuntime().
- Fix misleading description of `@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion` feature flag.
- Mark nodejs18.x as deprecated (it's no longer in maintenance upstream, folks should upgrade)

Nodejs18 is no longer in maintenance: https://nodejs.org/en/about/previous-releases
and will be deprecated by AWS on 2025 September 1 https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

NODE_LATEST still points to v18:
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L119

I see that there's been an issue about this since 2023: aws#28125

The feature flag? `@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion`
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda-nodejs/lib/function.ts#L182
As written, gives you NODE_LATEST (v18) by default instead of v16.

The best practice seems to be to use determineLatestNodeRuntime()
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts#L414,
But even that can default to v18.
@ahammond ahammond requested a review from a team as a code owner April 11, 2025 22:42
@aws-cdk-automation aws-cdk-automation requested a review from a team April 11, 2025 22:42
@github-actions github-actions bot added valued-contributor [Pilot] contributed between 6-12 PRs to the CDK p2 labels Apr 11, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 and removed p2 labels Apr 11, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 12, 2025 00:31

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: c2bde26
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@ahammond
Copy link
Contributor Author

ahammond commented Apr 14, 2025

Unsurprisingly, this changes snapshots for 11 "unrelated" test suites. Before I invest more time in this, I would like to get a commitment around having this merged.

@hye-click-up
Copy link

We need this as our company need the latest support of nodejs

@trevor-clickup
Copy link

This is very odd to use latest as a deprecated version? Can we move this to something that is representative of what the upstream nodejs project is listing as a usable version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/medium Medium work item – several days of effort p1 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-cdk-lib: NODEJS_LATEST still points to nodejs18.x
4 participants