Skip to content

Commit

Permalink
feat(lambda): nodejs14.x supports inline code (#16131)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
gkaskonas authored Aug 24, 2021
1 parent 9c39bcb commit 305f683
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -331,6 +381,11 @@
"Value": {
"Ref": "PYTHON38A180AE47"
}
},
"NODEJS14XfunctionName": {
"Value": {
"Ref": "NODEJS14X930214A3"
}
}
}
}
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit 305f683

Please sign in to comment.