diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json index c7d5de3447f75..24d9a7c90020e 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json @@ -1,7 +1,7 @@ { "version": "38.0.1", "files": { - "0d74b5a40240d8fe0a138cb28488a1136484e5a20037fc9a6f57fd6f4426bd7b": { + "b223922b760df92bbe6af9e57188ae1e68bacb7d7db1c238410c9f14b59bc627": { "source": { "path": "aws-cdk-lambda-runtime-inlinecode.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "0d74b5a40240d8fe0a138cb28488a1136484e5a20037fc9a6f57fd6f4426bd7b.json", + "objectKey": "b223922b760df92bbe6af9e57188ae1e68bacb7d7db1c238410c9f14b59bc627.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json index 80ff8a858dabc..82f766c09aeee 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json @@ -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": { @@ -386,6 +436,11 @@ "Value": { "Ref": "NODEJS20X70A25ADE" } + }, + "NODEJS22XfunctionName": { + "Value": { + "Ref": "NODEJS22X911196A1" + } } }, "Parameters": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json index e6bd9b0e6ba7f..040005e8d5848 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json @@ -19,7 +19,7 @@ "notificationArns": [], "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0d74b5a40240d8fe0a138cb28488a1136484e5a20037fc9a6f57fd6f4426bd7b.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/b223922b760df92bbe6af9e57188ae1e68bacb7d7db1c238410c9f14b59bc627.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -161,6 +161,24 @@ "data": "NODEJS20XfunctionName" } ], + "/aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "NODEJS22XServiceRole8FE2F7A5" + } + ], + "/aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "NODEJS22X911196A1" + } + ], + "/aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X-functionName": [ + { + "type": "aws:cdk:logicalId", + "data": "NODEJS22XfunctionName" + } + ], "/aws-cdk-lambda-runtime-inlinecode/BootstrapVersion": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json index cba00605f33f4..7cd9d8c3cfc34 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json @@ -701,6 +701,105 @@ "version": "0.0.0" } }, + "NODEJS_22_X": { + "id": "NODEJS_22_X", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "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" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function(event) { return \"success\" }" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "NODEJS22XServiceRole8FE2F7A5", + "Arn" + ] + }, + "runtime": "nodejs22.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "NODEJS_22_X-functionName": { + "id": "NODEJS_22_X-functionName", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_22_X-functionName", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-cdk-lambda-runtime-inlinecode/BootstrapVersion", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts index 3e7c206a3087d..3ed1bfb6435e3 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts @@ -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], }); diff --git a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts index 72da4b88b60c5..4c7917380fa7e 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts @@ -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.