Skip to content
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

s3: Custom s3 auto delete lambda is still using node 20.x #33622

Closed
1 task
yaseen104 opened this issue Feb 28, 2025 · 4 comments
Closed
1 task

s3: Custom s3 auto delete lambda is still using node 20.x #33622

yaseen104 opened this issue Feb 28, 2025 · 4 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. effort/medium Medium work item – several days of effort p3

Comments

@yaseen104
Copy link

Describe the bug

After 2.168.0 there was a support for node 22.x.
Below is the code
const s3BucketWeb = new s3.Bucket(stack,${envProps.environmentName}-s3-web, { // Block all public access blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, // When stack is deleted, delete this bucket also removalPolicy: cdk.RemovalPolicy.DESTROY, // Delete contained objects when bucket is deleted autoDeleteObjects: true });

But the CustomS3AutoDelete Lambda is till taking the node 20.x
Tried the version till 2.180.0.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

The node version should be updated to 22.

Current Behavior

It is still taking node 20

Reproduction Steps

const s3BucketWeb = new s3.Bucket(stack,${envProps.environmentName}-s3-web, { // Block all public access blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, // When stack is deleted, delete this bucket also removalPolicy: cdk.RemovalPolicy.DESTROY, // Delete contained objects when bucket is deleted autoDeleteObjects: true });

Using this code, this will create the auto delete objects

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.170.0

Framework Version

No response

Node.js Version

20

OS

windows

Language

TypeScript

Language Version

No response

Other information

No response

@yaseen104 yaseen104 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 28, 2025
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Feb 28, 2025
@mrgrain mrgrain changed the title (module name): (short issue description) Custom s3 auto delete lambda is still using node 20.x (s3): Custom s3 auto delete lambda is still using node 20.x Feb 28, 2025
@mrgrain mrgrain changed the title (s3): Custom s3 auto delete lambda is still using node 20.x s3: Custom s3 auto delete lambda is still using node 20.x Feb 28, 2025
@pahud
Copy link
Contributor

pahud commented Feb 28, 2025

Hi @yaseen104,

Thank you for reporting this issue. You're correct that the CustomS3AutoDelete Lambda function is still using Node.js 20.x despite Node.js 22.x being a supported runtime in AWS CDK since version 2.168.0.

After investigating, I can explain why this is happening:

  1. The S3 bucket's autoDeleteObjects: true option creates a custom resource that uses the AutoDeleteObjectsProvider class. This provider determines which Node.js runtime to use by calling a function named determineLatestNodeRuntimeName.

  2. This function checks the CDK's regional fact database (in fact-tables.ts) to determine the latest available Node.js runtime for the deployment region. Looking at this file, I can see that the current mapping specifies:

export const LATEST_NODE_RUNTIME_MAP: Record<Partition, string> = {
[Partition.Default]: Runtime.NODE_20,
[Partition.Cn]: Runtime.NODE_20,
[Partition.UsGov]: Runtime.NODE_20,
[Partition.UsIso]: Runtime.NODE_18,
[Partition.UsIsoB]: Runtime.NODE_18,
[Partition.UsIsoF]: Runtime.NODE_18,
[Partition.EuIsoE]: Runtime.NODE_18,
};

  1. The current approach is to only update the "latest" runtime designation when a runtime is available in all AWS regions, including specialized ones like GovCloud and China regions.

This behavior is by design rather than a bug. AWS CDK is being cautious about updating the "latest" runtime designation to ensure consistent behavior across all regions. Once Node.js 22.x becomes available in all regions, the CDK team will likely update the LATEST_NODE_RUNTIME_MAP to use it.

I'll bring this issue up to the team to review and re-evaluate if it's OK to bump the latest to node22.

@pahud pahud added p3 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 28, 2025
@pahud
Copy link
Contributor

pahud commented Feb 28, 2025

related to #27003 (comment)

@SimonCMoore
Copy link

As Pahud says and is as intended and tracked in #27003 we are currently using Node 20 in commercial regions for custom resources. For lambdas you author you can use NODEJS_22_X \for the runtime. I will close this in favour of the tracking issue.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. effort/medium Medium work item – several days of effort p3
Projects
None yet
Development

No branches or pull requests

3 participants