Skip to content

Commit baa8561

Browse files
authored
feat(lambda): add NodeJS 22.x support (#32104)
### Issue # (if applicable) NA ### Reason for this change Adds NodeJs 22.x Runtime to the available [Lambda Runtimes constants](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Runtime.html#initializer) ### Description of how you validated changes Have added integration tests to validate the runtime support ### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e1a2f68 commit baa8561

File tree

6 files changed

+187
-3
lines changed

6 files changed

+187
-3
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,56 @@
349349
"DependsOn": [
350350
"NODEJS20XServiceRole188A4E38"
351351
]
352+
},
353+
"NODEJS22XServiceRole8FE2F7A5": {
354+
"Type": "AWS::IAM::Role",
355+
"Properties": {
356+
"AssumeRolePolicyDocument": {
357+
"Statement": [
358+
{
359+
"Action": "sts:AssumeRole",
360+
"Effect": "Allow",
361+
"Principal": {
362+
"Service": "lambda.amazonaws.com"
363+
}
364+
}
365+
],
366+
"Version": "2012-10-17"
367+
},
368+
"ManagedPolicyArns": [
369+
{
370+
"Fn::Join": [
371+
"",
372+
[
373+
"arn:",
374+
{
375+
"Ref": "AWS::Partition"
376+
},
377+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
378+
]
379+
]
380+
}
381+
]
382+
}
383+
},
384+
"NODEJS22X911196A1": {
385+
"Type": "AWS::Lambda::Function",
386+
"Properties": {
387+
"Code": {
388+
"ZipFile": "exports.handler = async function(event) { return \"success\" }"
389+
},
390+
"Handler": "index.handler",
391+
"Role": {
392+
"Fn::GetAtt": [
393+
"NODEJS22XServiceRole8FE2F7A5",
394+
"Arn"
395+
]
396+
},
397+
"Runtime": "nodejs22.x"
398+
},
399+
"DependsOn": [
400+
"NODEJS22XServiceRole8FE2F7A5"
401+
]
352402
}
353403
},
354404
"Outputs": {
@@ -386,6 +436,11 @@
386436
"Value": {
387437
"Ref": "NODEJS20X70A25ADE"
388438
}
439+
},
440+
"NODEJS22XfunctionName": {
441+
"Value": {
442+
"Ref": "NODEJS22X911196A1"
443+
}
389444
}
390445
},
391446
"Parameters": {

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json

Lines changed: 99 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ const node20xfn = new Function(stack, 'NODEJS_20_X', {
6565
});
6666
new CfnOutput(stack, 'NODEJS_20_X-functionName', { value: node20xfn.functionName });
6767

68+
const node22xfn = new Function(stack, 'NODEJS_22_X', {
69+
code: new InlineCode('exports.handler = async function(event) { return "success" }'),
70+
handler: 'index.handler',
71+
runtime: Runtime.NODEJS_22_X,
72+
});
73+
new CfnOutput(stack, 'NODEJS_22_X-functionName', { value: node22xfn.functionName });
74+
6875
new integ.IntegTest(app, 'lambda-runtime-inlinecode', {
6976
testCases: [stack],
7077
});

packages/aws-cdk-lib/aws-lambda/lib/runtime.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ export class Runtime {
118118
*/
119119
public static readonly NODEJS_LATEST = new Runtime('nodejs18.x', RuntimeFamily.NODEJS, { supportsInlineCode: true, isVariable: true });
120120

121+
/**
122+
* The NodeJS 22.x runtime (nodejs22.x)
123+
*/
124+
public static readonly NODEJS_22_X = new Runtime('nodejs22.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });
125+
121126
/**
122127
* The Python 2.7 runtime (python2.7)
123128
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.

0 commit comments

Comments
 (0)