Skip to content

Commit 80564ea

Browse files
abetomoDeviaVir
authored andcommitted
Fix version of Node.js supported by AWS Lambda (#197)
* Fix version of Node.js supported by AWS Lambda https://aws.amazon.com/jp/about-aws/whats-new/2017/03/aws-lambda-supports-node-js-6-10/ http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html * Changed README on 'Node.js Runtime Configuration' AWS Lambda now supports Node.js 6.10 and Node.js 4.3. * Changed the default value of AWS_RUNTIME from nodejs4.3 to nodejs6.10 AWS Lambda now supports Node.js 6.10 and Node.js 4.3
1 parent bcc8dfc commit 80564ea

File tree

5 files changed

+9
-40
lines changed

5 files changed

+9
-40
lines changed

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $ node-lambda run --help
6969
-H, --handler [index.handler] Lambda Handler {index.handler}
7070
-j, --eventFile [event.json] Event JSON File
7171
-f, --configFile [] Path to file holding secret environment variables (e.g. "deploy.env")
72-
-u, --runtime [nodejs4.3] Lambda Runtime {nodejs4.3, nodejs} - "nodejs4.3" is the current standard, "nodejs" is v0.10.36
72+
-u, --runtime [nodejs6.10] Lambda Runtime {nodejs6.10, nodejs4.3}
7373
-t, --timeout [3] Lambda Timeout in seconds (max of 300)
7474
-x, --contextFile [context.json] Context JSON file
7575
```
@@ -120,7 +120,7 @@ $ node-lambda deploy --help
120120
-m, --memorySize [128] Lambda Memory Size
121121
-t, --timeout [3] Lambda Timeout
122122
-d, --description [missing] Lambda Description
123-
-u, --runtime [nodejs4.3] Lambda Runtime {nodejs4.3, nodejs} - "nodejs4.3" is the current standard, "nodejs" is v0.10.36
123+
-u, --runtime [nodejs6.10] Lambda Runtime {nodejs6.10, nodejs4.3}
124124
-p, --publish [false] This boolean parameter can be used to request AWS Lambda to create the Lambda function and publish a version as an atomic operation
125125
-L, --lambdaVersion [custom-version] Lambda Version
126126
-f, --configFile [] Path to file holding secret environment variables (e.g. "deploy.env")
@@ -137,19 +137,7 @@ AWS Lambda will let you set environment variables for your function. Use the sam
137137

138138
## Node.js Runtime Configuration
139139

140-
AWS Lambda now supports Node.js v4.3.2, and there have been some [API changes](http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-using-old-runtime.html) for the new version. Most notably,
141-
`context.done()`, `context.succeed()`, and `context.fail()` are deprecated in favor of the Node convention of passing in
142-
a callback function. These will still work for now for backward compatibility, but are no longer recommended.
143-
144-
v0.10.36 is still supported, and can be targeted by changing the `AWS_RUNTIME` value to `nodejs` in the `.env` file.
145-
146-
Runtime context options available :
147-
148-
- context.getRemainingTimeInMillis()
149-
- context.done() ***deprecated***
150-
- context.fail() ***deprecated***
151-
- context.succeed() ***deprecated***
152-
140+
AWS Lambda now supports Node.js 6.10 and Node.js 4.3. Please also check the [Programming Model (Node.js)](http://docs.aws.amazon.com/lambda/latest/dg/programming-model.html) page.
153141

154142
## Post install script
155143
When running `node-lambda deploy` if you need to do some action after `npm install --production` and before deploying to AWS Lambda (e.g. replace some modules with precompiled ones or download some libraries, replace some config file depending on environment) you can create `post_install.sh` script. If the file exists the script will be executed (and output shown after execution) if not it is skipped. Environment string is passed to script as first parameter so you can use it if needed. Make sure that the script is executable.

bin/node-lambda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var AWS_MEMORY_SIZE = process.env.AWS_MEMORY_SIZE || 128;
2525
var AWS_TIMEOUT = process.env.AWS_TIMEOUT || 60;
2626
var AWS_RUN_TIMEOUT = process.env.AWS_RUN_TIMEOUT || 3;
2727
var AWS_DESCRIPTION = process.env.AWS_DESCRIPTION || packageJson.description || '';
28-
var AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs4.3';
28+
var AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs6.10';
2929
var AWS_PUBLISH = process.env.AWS_PUBLISH || false;
3030
var AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION || '';
3131
var AWS_VPC_SUBNETS = process.env.AWS_VPC_SUBNETS || '';

lib/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AWS_HANDLER=index.handler
1010
AWS_MEMORY_SIZE=128
1111
AWS_TIMEOUT=3
1212
AWS_DESCRIPTION=
13-
AWS_RUNTIME=nodejs4.3
13+
AWS_RUNTIME=nodejs6.10
1414
AWS_VPC_SUBNETS=
1515
AWS_VPC_SECURITY_GROUPS=
1616
EXCLUDE_GLOBS="event.json"

lib/main.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,37 +74,18 @@ Lambda.prototype._runHandler = function (handler, event, program, context) {
7474
}
7575
};
7676

77-
var isNode43 = (program.runtime === "nodejs4.3");
78-
context.succeed = function (result) {
79-
if (isNode43) {
80-
console.log('context.succeed() is deprecated with Node.js 4.3 runtime');
81-
}
82-
callback(null, result);
83-
};
84-
context.fail = function (error) {
85-
if (isNode43) {
86-
console.log('context.fail() is deprecated with Node.js 4.3 runtime');
87-
}
88-
callback(error);
89-
};
90-
context.done = function () {
91-
if (isNode43) {
92-
console.log('context.done() is deprecated with Node.js 4.3 runtime');
93-
}
94-
callback();
95-
};
9677
context.getRemainingTimeInMillis = function () {
9778
var currentTime = new Date();
9879
return timeout - (currentTime - startTime);
9980
};
10081

10182
switch(program.runtime) {
102-
case "nodejs":
103-
handler(event, context);
104-
break;
10583
case "nodejs4.3":
10684
handler(event, context, callback);
10785
break;
86+
case "nodejs6.10":
87+
handler(event, context, callback);
88+
break;
10889
default:
10990
console.error("Runtime [" + runtime + "] is not supported.");
11091
}

test/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var originalProgram = {
2121
memorySize: 128,
2222
timeout: 3,
2323
description: '',
24-
runtime: 'nodejs',
24+
runtime: 'nodejs6.10',
2525
region: 'us-east-1,us-west-2,eu-west-1',
2626
eventFile: 'event.json',
2727
contextFile: 'context.json',

0 commit comments

Comments
 (0)