From 305f683e86cca221705c0138572faa38043396eb Mon Sep 17 00:00:00 2001 From: Giedrius Kaskonas <57504623+gkaskonas@users.noreply.github.com> Date: Tue, 24 Aug 2021 15:47:49 +0100 Subject: [PATCH] feat(lambda): nodejs14.x supports inline code (#16131) Cloudformation now supports Inline code for NodeJS14 runtime. Updating CDK to reflect that ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-lambda/lib/runtime.ts | 2 +- .../integ.runtime.inlinecode.expected.json | 55 +++++++++++++++++++ .../test/integ.runtime.inlinecode.ts | 7 +++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-lambda/lib/runtime.ts b/packages/@aws-cdk/aws-lambda/lib/runtime.ts index e354e5862cc6e..ae26ca066e1c9 100644 --- a/packages/@aws-cdk/aws-lambda/lib/runtime.ts +++ b/packages/@aws-cdk/aws-lambda/lib/runtime.ts @@ -77,7 +77,7 @@ export class Runtime { /** * The NodeJS 14.x runtime (nodejs14.x) */ - public static readonly NODEJS_14_X = new Runtime('nodejs14.x', RuntimeFamily.NODEJS, { supportsInlineCode: false }); + public static readonly NODEJS_14_X = new Runtime('nodejs14.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }); /** * The Python 2.7 runtime (python2.7) diff --git a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json index 30d39828cc39d..59961a0755b84 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json @@ -299,6 +299,56 @@ "DependsOn": [ "PYTHON38ServiceRole3EA86BBE" ] + }, + "NODEJS14XServiceRole4523ECDB": { + "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" + ] + ] + } + ] + } + }, + "NODEJS14X930214A3": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function(event) { return \"success\" }" + }, + "Role": { + "Fn::GetAtt": [ + "NODEJS14XServiceRole4523ECDB", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "nodejs14.x" + }, + "DependsOn": [ + "NODEJS14XServiceRole4523ECDB" + ] } }, "Outputs": { @@ -331,6 +381,11 @@ "Value": { "Ref": "PYTHON38A180AE47" } + }, + "NODEJS14XfunctionName": { + "Value": { + "Ref": "NODEJS14X930214A3" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts index 56f5bd27f7746..3bde19e5cd22b 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts @@ -57,4 +57,11 @@ const python38 = new Function(stack, 'PYTHON_3_8', { }); new CfnOutput(stack, 'PYTHON_3_8-functionName', { value: python38.functionName }); +const node14xfn = new Function(stack, 'NODEJS_14_X', { + code: new InlineCode('exports.handler = async function(event) { return "success" }'), + handler: 'index.handler', + runtime: Runtime.NODEJS_14_X, +}); +new CfnOutput(stack, 'NODEJS_14_X-functionName', { value: node14xfn.functionName }); + app.synth();