From a07538bbe5cb3fb4ab66a2119cf429c8eb4551a4 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy Date: Wed, 8 Nov 2023 11:50:17 -0500 Subject: [PATCH] feat(lambda): node20 runtime --- ...-cdk-lambda-runtime-inlinecode.assets.json | 6 +- ...dk-lambda-runtime-inlinecode.template.json | 69 +++++++++-- .../cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 23 +++- .../tree.json | 115 ++++++++++++++++-- .../test/integ.runtime.inlinecode.ts | 7 ++ .../aws-cdk-lib/aws-lambda/lib/runtime.ts | 5 + 8 files changed, 207 insertions(+), 22 deletions(-) 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 7597e8e33a542..451cfcd3f0f27 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": "31.0.0", + "version": "34.0.0", "files": { - "e662217761cf2ba05977dbcac8535cc2b9b3175c8d3c799d31fd5ef6b0c08ac6": { + "ab212011785d32ea6de009fda91d48cf0cd3411ffebcdd7a6b62ccd841c00906": { "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": "e662217761cf2ba05977dbcac8535cc2b9b3175c8d3c799d31fd5ef6b0c08ac6.json", + "objectKey": "ab212011785d32ea6de009fda91d48cf0cd3411ffebcdd7a6b62ccd841c00906.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 e1f43849b372b..c86c08156141a 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 @@ -37,13 +37,13 @@ "Code": { "ZipFile": "def handler(event, context):\n return \"success\"" }, + "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "PYTHON37ServiceRoleDE7E561E", "Arn" ] }, - "Handler": "index.handler", "Runtime": "python3.7" }, "DependsOn": [ @@ -87,13 +87,13 @@ "Code": { "ZipFile": "def handler(event, context):\n return \"success\"" }, + "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "PYTHON38ServiceRole3EA86BBE", "Arn" ] }, - "Handler": "index.handler", "Runtime": "python3.8" }, "DependsOn": [ @@ -137,13 +137,13 @@ "Code": { "ZipFile": "def handler(event, context):\n return \"success\"" }, + "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "PYTHON39ServiceRole53E964DF", "Arn" ] }, - "Handler": "index.handler", "Runtime": "python3.9" }, "DependsOn": [ @@ -187,13 +187,13 @@ "Code": { "ZipFile": "def handler(event, context):\n return \"success\"" }, + "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "PYTHON310ServiceRole65985CC8", "Arn" ] }, - "Handler": "index.handler", "Runtime": "python3.10" }, "DependsOn": [ @@ -237,13 +237,13 @@ "Code": { "ZipFile": "exports.handler = async function(event) { return \"success\" }" }, + "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "NODEJS14XServiceRole4523ECDB", "Arn" ] }, - "Handler": "index.handler", "Runtime": "nodejs14.x" }, "DependsOn": [ @@ -287,13 +287,13 @@ "Code": { "ZipFile": "exports.handler = async function(event) { return \"success\" }" }, + "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "NODEJS16XServiceRoleB9DAFDFD", "Arn" ] }, - "Handler": "index.handler", "Runtime": "nodejs16.x" }, "DependsOn": [ @@ -337,18 +337,68 @@ "Code": { "ZipFile": "exports.handler = async function(event) { return \"success\" }" }, + "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "NODEJS18XServiceRole4D18036A", "Arn" ] }, - "Handler": "index.handler", "Runtime": "nodejs18.x" }, "DependsOn": [ "NODEJS18XServiceRole4D18036A" ] + }, + "NODEJS20XServiceRole188A4E38": { + "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" + ] + ] + } + ] + } + }, + "NODEJS20X70A25ADE": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function(event) { return \"success\" }" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "NODEJS20XServiceRole188A4E38", + "Arn" + ] + }, + "Runtime": "nodejs20.x" + }, + "DependsOn": [ + "NODEJS20XServiceRole188A4E38" + ] } }, "Outputs": { @@ -386,6 +436,11 @@ "Value": { "Ref": "NODEJS18X7B6E6033" } + }, + "NODEJS20XfunctionName": { + "Value": { + "Ref": "NODEJS20X70A25ADE" + } } }, "Parameters": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out index 7925065efbcc4..2313ab5436501 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"31.0.0"} \ No newline at end of file +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json index 4354a1a993301..43e2d3bc638c2 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "31.0.0", + "version": "34.0.0", "testCases": { "integ.runtime.inlinecode": { "stacks": [ 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 7bcc74b60c1e1..8de8c51ed33f1 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 @@ -1,5 +1,5 @@ { - "version": "31.0.0", + "version": "34.0.0", "artifacts": { "aws-cdk-lambda-runtime-inlinecode.assets": { "type": "cdk:asset-manifest", @@ -14,10 +14,11 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "aws-cdk-lambda-runtime-inlinecode.template.json", + "terminationProtection": false, "validateOnSynth": false, "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}/e662217761cf2ba05977dbcac8535cc2b9b3175c8d3c799d31fd5ef6b0c08ac6.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ab212011785d32ea6de009fda91d48cf0cd3411ffebcdd7a6b62ccd841c00906.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -159,6 +160,24 @@ "data": "NODEJS18XfunctionName" } ], + "/aws-cdk-lambda-runtime-inlinecode/NODEJS_20_X/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "NODEJS20XServiceRole188A4E38" + } + ], + "/aws-cdk-lambda-runtime-inlinecode/NODEJS_20_X/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "NODEJS20X70A25ADE" + } + ], + "/aws-cdk-lambda-runtime-inlinecode/NODEJS_20_X-functionName": [ + { + "type": "aws:cdk:logicalId", + "data": "NODEJS20XfunctionName" + } + ], "/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 df061cdb0f61b..c0b65a6e5146b 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 @@ -78,13 +78,13 @@ "code": { "zipFile": "def handler(event, context):\n return \"success\"" }, + "handler": "index.handler", "role": { "Fn::GetAtt": [ "PYTHON37ServiceRoleDE7E561E", "Arn" ] }, - "handler": "index.handler", "runtime": "python3.7" } }, @@ -177,13 +177,13 @@ "code": { "zipFile": "def handler(event, context):\n return \"success\"" }, + "handler": "index.handler", "role": { "Fn::GetAtt": [ "PYTHON38ServiceRole3EA86BBE", "Arn" ] }, - "handler": "index.handler", "runtime": "python3.8" } }, @@ -276,13 +276,13 @@ "code": { "zipFile": "def handler(event, context):\n return \"success\"" }, + "handler": "index.handler", "role": { "Fn::GetAtt": [ "PYTHON39ServiceRole53E964DF", "Arn" ] }, - "handler": "index.handler", "runtime": "python3.9" } }, @@ -375,13 +375,13 @@ "code": { "zipFile": "def handler(event, context):\n return \"success\"" }, + "handler": "index.handler", "role": { "Fn::GetAtt": [ "PYTHON310ServiceRole65985CC8", "Arn" ] }, - "handler": "index.handler", "runtime": "python3.10" } }, @@ -474,13 +474,13 @@ "code": { "zipFile": "exports.handler = async function(event) { return \"success\" }" }, + "handler": "index.handler", "role": { "Fn::GetAtt": [ "NODEJS14XServiceRole4523ECDB", "Arn" ] }, - "handler": "index.handler", "runtime": "nodejs14.x" } }, @@ -573,13 +573,13 @@ "code": { "zipFile": "exports.handler = async function(event) { return \"success\" }" }, + "handler": "index.handler", "role": { "Fn::GetAtt": [ "NODEJS16XServiceRoleB9DAFDFD", "Arn" ] }, - "handler": "index.handler", "runtime": "nodejs16.x" } }, @@ -672,13 +672,13 @@ "code": { "zipFile": "exports.handler = async function(event) { return \"success\" }" }, + "handler": "index.handler", "role": { "Fn::GetAtt": [ "NODEJS18XServiceRole4D18036A", "Arn" ] }, - "handler": "index.handler", "runtime": "nodejs18.x" } }, @@ -701,6 +701,105 @@ "version": "0.0.0" } }, + "NODEJS_20_X": { + "id": "NODEJS_20_X", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_20_X", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_20_X/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_20_X/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_20_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_20_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": [ + "NODEJS20XServiceRole188A4E38", + "Arn" + ] + }, + "runtime": "nodejs20.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_20_X-functionName": { + "id": "NODEJS_20_X-functionName", + "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_20_X-functionName", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-cdk-lambda-runtime-inlinecode/BootstrapVersion", @@ -728,7 +827,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.270" + "version": "10.2.70" } } }, 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 2349e28041f96..5adebdcc03b64 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 @@ -64,4 +64,11 @@ const node18xfn = new Function(stack, 'NODEJS_18_X', { }); new CfnOutput(stack, 'NODEJS_18_X-functionName', { value: node18xfn.functionName }); +const node20xfn = new Function(stack, 'NODEJS_20_X', { + code: new InlineCode('exports.handler = async function(event) { return "success" }'), + handler: 'index.handler', + runtime: Runtime.NODEJS_20_X, +}); +new CfnOutput(stack, 'NODEJS_20_X-functionName', { value: node20xfn.functionName }); + app.synth(); diff --git a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts index 4113d4c23e5c3..d180aaeffd216 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts @@ -104,6 +104,11 @@ export class Runtime { */ public static readonly NODEJS_18_X = new Runtime('nodejs18.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }); + /** + * The NodeJS 20.x runtime (nodejs20.x) + */ + public static readonly NODEJS_20_X = new Runtime('nodejs20.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }); + /** * The latest NodeJS version currently available */