Skip to content

Commit

Permalink
feat(lambda): add NodeJS 22.x support (#32104)
Browse files Browse the repository at this point in the history
### 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*
  • Loading branch information
Vandita2020 authored Nov 20, 2024
1 parent e1a2f68 commit baa8561
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,56 @@
"DependsOn": [
"NODEJS20XServiceRole188A4E38"
]
},
"NODEJS22XServiceRole8FE2F7A5": {
"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"
]
]
}
]
}
},
"NODEJS22X911196A1": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "exports.handler = async function(event) { return \"success\" }"
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"NODEJS22XServiceRole8FE2F7A5",
"Arn"
]
},
"Runtime": "nodejs22.x"
},
"DependsOn": [
"NODEJS22XServiceRole8FE2F7A5"
]
}
},
"Outputs": {
Expand Down Expand Up @@ -386,6 +436,11 @@
"Value": {
"Ref": "NODEJS20X70A25ADE"
}
},
"NODEJS22XfunctionName": {
"Value": {
"Ref": "NODEJS22X911196A1"
}
}
},
"Parameters": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ const node20xfn = new Function(stack, 'NODEJS_20_X', {
});
new CfnOutput(stack, 'NODEJS_20_X-functionName', { value: node20xfn.functionName });

const node22xfn = new Function(stack, 'NODEJS_22_X', {
code: new InlineCode('exports.handler = async function(event) { return "success" }'),
handler: 'index.handler',
runtime: Runtime.NODEJS_22_X,
});
new CfnOutput(stack, 'NODEJS_22_X-functionName', { value: node22xfn.functionName });

new integ.IntegTest(app, 'lambda-runtime-inlinecode', {
testCases: [stack],
});
5 changes: 5 additions & 0 deletions packages/aws-cdk-lib/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export class Runtime {
*/
public static readonly NODEJS_LATEST = new Runtime('nodejs18.x', RuntimeFamily.NODEJS, { supportsInlineCode: true, isVariable: true });

/**
* The NodeJS 22.x runtime (nodejs22.x)
*/
public static readonly NODEJS_22_X = new Runtime('nodejs22.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });

/**
* The Python 2.7 runtime (python2.7)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
Expand Down

0 comments on commit baa8561

Please sign in to comment.