Skip to content

Commit 862496b

Browse files
authored
Node 14 support (#2410)
Add node 14 Lambda support
1 parent 10bb86b commit 862496b

File tree

16 files changed

+82
-16
lines changed

16 files changed

+82
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Nodejs14.x Lambda support"
4+
}

core/src/software/aws/toolkits/core/lambda/LambdaRuntime.kt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum class LambdaRuntime(
1313
) {
1414
NODEJS10_X(Runtime.NODEJS10_X),
1515
NODEJS12_X(Runtime.NODEJS12_X),
16+
NODEJS14_X(Runtime.NODEJS14_X, minSamDebugging = "1.17.0", minSamInit = "1.17.0"),
1617
JAVA8(Runtime.JAVA8),
1718
JAVA8_AL2(Runtime.JAVA8_AL2, minSamDebugging = "1.2.0"),
1819
JAVA11(Runtime.JAVA11),

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publishChannel=
1111
# Common dependencies
1212
ideProfileName=2020.1
1313
kotlinVersion=1.4.21
14-
awsSdkVersion=2.15.60
14+
awsSdkVersion=2.15.75
1515
coroutinesVersion=1.3.3
1616
ideaPluginVersion=0.6.3
1717
ktlintVersion=0.39.0

jetbrains-ultimate/it/software/aws/toolkits/jetbrains/services/lambda/nodejs/NodeJsLocalLambdaRunConfigurationIntegrationTest.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class NodeJsLocalLambdaRunConfigurationIntegrationTest(private val runtime: Runt
3838
@Parameterized.Parameters(name = "{0}")
3939
fun parameters(): Collection<Array<Runtime>> = listOf(
4040
arrayOf(Runtime.NODEJS10_X),
41-
arrayOf(Runtime.NODEJS12_X)
41+
arrayOf(Runtime.NODEJS12_X),
42+
arrayOf(Runtime.NODEJS14_X)
4243
)
4344
}
4445

jetbrains-ultimate/resources/META-INF/ext-nodejs.xml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<sam.runtimeDebugSupport id="NODEJS" implementationClass="software.aws.toolkits.jetbrains.services.lambda.nodejs.NodeJsRuntimeDebugSupport"/>
1414
<sam.imageDebuggerSupport implementation="software.aws.toolkits.jetbrains.services.lambda.nodejs.NodeJs10ImageDebug"/>
1515
<sam.imageDebuggerSupport implementation="software.aws.toolkits.jetbrains.services.lambda.nodejs.NodeJs12ImageDebug"/>
16+
<sam.imageDebuggerSupport implementation="software.aws.toolkits.jetbrains.services.lambda.nodejs.NodeJs14ImageDebug"/>
1617
<sam.projectWizard id="NODEJS" implementationClass="software.aws.toolkits.jetbrains.services.lambda.nodejs.NodeJsSamProjectWizard"/>
1718
</extensions>
1819

jetbrains-ultimate/src/software/aws/toolkits/jetbrains/services/lambda/nodejs/NodeJsImageDebugSupport.kt

+5
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ class NodeJs12ImageDebug : NodeJsImageDebugSupport() {
3434
override val id: String = LambdaRuntime.NODEJS12_X.toString()
3535
override fun displayName() = LambdaRuntime.NODEJS12_X.toString().capitalize()
3636
}
37+
38+
class NodeJs14ImageDebug : NodeJsImageDebugSupport() {
39+
override val id: String = LambdaRuntime.NODEJS14_X.toString()
40+
override fun displayName() = LambdaRuntime.NODEJS14_X.toString().capitalize()
41+
}

jetbrains-ultimate/src/software/aws/toolkits/jetbrains/services/lambda/nodejs/NodeJsRuntimeGroup.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class NodeJsRuntimeGroup : SdkBasedRuntimeGroup() {
2525

2626
override val supportedRuntimes = listOf(
2727
LambdaRuntime.NODEJS10_X,
28-
LambdaRuntime.NODEJS12_X
28+
LambdaRuntime.NODEJS12_X,
29+
LambdaRuntime.NODEJS14_X
2930
)
3031

3132
override fun determineRuntime(module: Module): LambdaRuntime? = determineRuntime(module.project)
@@ -35,6 +36,7 @@ class NodeJsRuntimeGroup : SdkBasedRuntimeGroup() {
3536
when {
3637
it.major <= 10 -> LambdaRuntime.NODEJS10_X
3738
it.major <= 12 -> LambdaRuntime.NODEJS12_X
39+
it.major <= 14 -> LambdaRuntime.NODEJS14_X
3840
else -> null
3941
}
4042
}

jetbrains-ultimate/src/software/aws/toolkits/jetbrains/services/lambda/nodejs/NodeJsSamProjectWizard.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class SamHelloWorldNodeJs : SamAppTemplateBased() {
5959

6060
override fun description() = message("sam.init.template.hello_world.description")
6161

62-
override fun supportedZipRuntimes(): Set<LambdaRuntime> = setOf(LambdaRuntime.NODEJS10_X, LambdaRuntime.NODEJS12_X)
62+
override fun supportedZipRuntimes(): Set<LambdaRuntime> = setOf(LambdaRuntime.NODEJS10_X, LambdaRuntime.NODEJS12_X, LambdaRuntime.NODEJS14_X)
6363

64-
override fun supportedImageRuntimes(): Set<LambdaRuntime> = setOf(LambdaRuntime.NODEJS10_X, LambdaRuntime.NODEJS12_X)
64+
override fun supportedImageRuntimes(): Set<LambdaRuntime> = setOf(LambdaRuntime.NODEJS10_X, LambdaRuntime.NODEJS12_X, LambdaRuntime.NODEJS14_X)
6565

6666
override val appTemplateName: String = "hello-world"
6767

jetbrains-ultimate/tst/software/aws/toolkits/jetbrains/services/lambda/nodejs/NodeJsHandlerCompletionProviderTest.kt

+6
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ class NodeJsHandlerCompletionProviderTest {
2626
val provider = HandlerCompletionProvider(projectRule.project, LambdaRuntime.NODEJS12_X)
2727
assertFalse(provider.isCompletionSupported)
2828
}
29+
30+
@Test
31+
fun completionIsNotSupportedNodeJs14X() {
32+
val provider = HandlerCompletionProvider(projectRule.project, LambdaRuntime.NODEJS14_X)
33+
assertFalse(provider.isCompletionSupported)
34+
}
2935
}

jetbrains-ultimate/tst/software/aws/toolkits/jetbrains/services/lambda/nodejs/NodeJsRuntimeGroupTest.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,22 @@ class NodeJsRuntimeGroupTest {
5555
}
5656

5757
@Test
58-
fun testRuntime12_13() {
58+
fun testRuntime12() {
5959
projectRule.project.setNodeJsInterpreterVersion(SemVer("v12.13.1", 12, 13, 1))
6060
val runtime = sut.determineRuntime(projectRule.project)
6161
assertThat(runtime).isEqualTo(LambdaRuntime.NODEJS12_X)
6262
}
6363

6464
@Test
65-
fun testRuntime13_0() {
66-
projectRule.project.setNodeJsInterpreterVersion(SemVer("v13.0.0", 13, 0, 0))
65+
fun testRuntime14() {
66+
projectRule.project.setNodeJsInterpreterVersion(SemVer("v14.0.0", 14, 0, 0))
67+
val runtime = sut.determineRuntime(projectRule.project)
68+
assertThat(runtime).isEqualTo(LambdaRuntime.NODEJS14_X)
69+
}
70+
71+
@Test
72+
fun testRuntime15_0() {
73+
projectRule.project.setNodeJsInterpreterVersion(SemVer("v15.0.0", 15, 0, 0))
6774
val runtime = sut.determineRuntime(projectRule.project)
6875
assertThat(runtime).isNull()
6976
}

testdata/samProjects/image/nodejs10.x/hello-world/app.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ let response;
22

33
exports.lambdaHandler = async (event, context) => {
44
try {
5-
// const ret = await axios(url);
65
response = {
76
'statusCode': 200,
87
'body': JSON.stringify({

testdata/samProjects/image/nodejs12.x/hello-world/package.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,5 @@
55
"main": "app.js",
66
"repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs",
77
"author": "SAM CLI",
8-
"license": "MIT",
9-
"dependencies": {
10-
"axios": "^0.18.0"
11-
},
12-
"scripts": {
13-
"test": "mocha tests/unit/"
14-
}
8+
"license": "MIT"
159
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM public.ecr.aws/lambda/nodejs:14
2+
3+
COPY app.js package.json ./
4+
5+
RUN npm install
6+
7+
CMD ["app.lambdaHandler"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let response;
2+
3+
exports.lambdaHandler = async (event, context) => {
4+
try {
5+
response = {
6+
'statusCode': 200,
7+
'body': JSON.stringify({
8+
message: JSON.stringify(event).toUpperCase(),
9+
})
10+
}
11+
} catch (err) {
12+
console.log(err);
13+
return err;
14+
}
15+
16+
return response
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "hello_world",
3+
"version": "1.0.0",
4+
"description": "hello world sample for NodeJS",
5+
"main": "app.js",
6+
"repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs",
7+
"author": "SAM CLI",
8+
"license": "MIT"
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
4+
Resources:
5+
SomeFunction:
6+
Type: AWS::Serverless::Function
7+
Properties:
8+
PackageType: Image
9+
Timeout: 900
10+
Metadata:
11+
DockerTag: v1
12+
DockerContext: ./hello-world
13+
Dockerfile: Dockerfile

0 commit comments

Comments
 (0)