-
Notifications
You must be signed in to change notification settings - Fork 4k
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
NodejsFunction: default runtime is NODEJS_16_X, even though it's not advised to use Node 16 anymore #30181
Comments
I would like to take this issue if the |
@timges Good afternoon. Thanks for reporting the issue. I used AWS CDK version lib/issue30181_nodejsfunction-stack import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lamndaNodejs from 'aws-cdk-lib/aws-lambda-nodejs';
import * as path from 'path';
export class Issue30181NodejsfunctionStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new lamndaNodejs.NodejsFunction(this, 'NodeJsLambda', {
entry: path.join(__dirname, "../lambda/hello.js"),
handler: 'hello.handler'
});
}
} lambda/hello.js exports.handler = async function(event) {
console.log("request:", JSON.stringify(event, undefined, 2));
return {
statusCode: 200,
headers: { "Content-Type": "text/plain" },
body: `Hello, CDK! You've hit ${event.path}\n`
};
}; package.json {
"name": "issue30181_nodejsfunction",
"version": "0.1.0",
"bin": {
"issue30181_nodejsfunction": "bin/issue30181_nodejsfunction.js"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"cdk": "cdk"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "20.12.7",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"aws-cdk": "2.141.0",
"ts-node": "^10.9.2",
"typescript": "~5.4.5"
},
"dependencies": {
"aws-cdk-lib": "2.141.0",
"constructs": "^10.0.0",
"source-map-support": "^0.5.21"
}
} Output of
Generated YAML template: Resources:
NodeJsLambdaServiceRoleFA44C8F8:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Metadata:
aws:cdk:path: Issue30181NodejsfunctionStack/NodeJsLambda/ServiceRole/Resource
NodeJsLambda3BAC57CB:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket:
Fn::Sub: cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}
S3Key: 00c4855d52e4e00779c647ff4229fb4960f46109943177ca985007e70783d4bc.zip
Environment:
Variables:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1"
Handler: hello.handler
Role:
Fn::GetAtt:
- NodeJsLambdaServiceRoleFA44C8F8
- Arn
Runtime: nodejs18.x
DependsOn:
- NodeJsLambdaServiceRoleFA44C8F8
Metadata:
aws:cdk:path: Issue30181NodejsfunctionStack/NodeJsLambda/Resource
aws:asset:path: asset.00c4855d52e4e00779c647ff4229fb4960f46109943177ca985007e70783d4bc
aws:asset:is-bundled: true
aws:asset:property: Code
...
... Upon deployment using However, upon checking the code, NodejsFunction construct uses getRuntime() helper method. It uses lambda.Runtime.NODEJS_LATEST (with current value Per CDK Developer Guide: Feature flags, the AWS CDK uses feature flags to enable potentially breaking behaviors in a release. Flags are stored as Runtime context values in cdk.json (or ~/.cdk.json). Issue is reproducible if I disable the feature flag This needs to be discussed with the team since the feature flag is enabled Thanks, |
Hey @timges, Ashish is correct, and I'll sum his comment up. There is a feature flag that changes this default from Generally, we keep changes to default values behind feature flags to maintain backwards compatibility. That was the case here. However, we will likely bump the actual default value as the Node 16 lambda runtime is deprecated and function create and update begin to be blocked by lambda itself. The deprecation date is June 12th. @daschaa, appreciate you offering to update this! However, I think our team will take this on. Node and SDK upgrades are something we are currently focusing on, so this is on our radar. I think we will want to be the ones pulling the trigger on updating this default. |
@daschaa @scanlonp @ashishdhingra, Thank you so much for your investigation and fast replies! 💪🏼 While it's important to stay backwards compatible, AWS's deprecation warnings suggest that it might be a good idea to update the default runtime rather soon. But since you're already aware of this topic, there seems to be no further action needed here. I'm comfortable having this issue closed 😊 |
|
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. |
Describe the bug
The default runtime of a NodejsFunction is currently set to NODEJS_16_X, which is a "soon to be depracted" runtime version. This results in [action required] email notifications by aws.
Expected Behavior
Node runtime version is the latest LTS by default, so that deploying a nodejs function without a specified runtime wont result in a [action required] notification
Current Behavior
Node runtime version is NODEJS_16_X by default, which triggers [action required] notifications
Reproduction Steps
Possible Solution
Update the default value of the NodejsFunction runtime parameter to match an LTS version
Additional Information/Context
No response
CDK CLI Version
v2.141.0
Framework Version
No response
Node.js Version
20
OS
macos
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: