diff --git a/README.md b/README.md index 6f4d8653..e6144ad9 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ $ node-lambda run --help -H, --handler [index.handler] Lambda Handler {index.handler} -j, --eventFile [event.json] Event JSON File -f, --configFile [] Path to file holding secret environment variables (e.g. "deploy.env") - -u, --runtime [nodejs4.3] Lambda Runtime {nodejs4.3, nodejs} - "nodejs4.3" is the current standard, "nodejs" is v0.10.36 + -u, --runtime [nodejs6.10] Lambda Runtime {nodejs6.10, nodejs4.3} -t, --timeout [3] Lambda Timeout in seconds (max of 300) -x, --contextFile [context.json] Context JSON file ``` @@ -120,7 +120,7 @@ $ node-lambda deploy --help -m, --memorySize [128] Lambda Memory Size -t, --timeout [3] Lambda Timeout -d, --description [missing] Lambda Description - -u, --runtime [nodejs4.3] Lambda Runtime {nodejs4.3, nodejs} - "nodejs4.3" is the current standard, "nodejs" is v0.10.36 + -u, --runtime [nodejs6.10] Lambda Runtime {nodejs6.10, nodejs4.3} -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 -L, --lambdaVersion [custom-version] Lambda Version -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 ## Node.js Runtime Configuration -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, -`context.done()`, `context.succeed()`, and `context.fail()` are deprecated in favor of the Node convention of passing in -a callback function. These will still work for now for backward compatibility, but are no longer recommended. - -v0.10.36 is still supported, and can be targeted by changing the `AWS_RUNTIME` value to `nodejs` in the `.env` file. - -Runtime context options available : - -- context.getRemainingTimeInMillis() -- context.done() ***deprecated*** -- context.fail() ***deprecated*** -- context.succeed() ***deprecated*** - +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. ## Post install script 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. diff --git a/bin/node-lambda b/bin/node-lambda index 9044c896..de905435 100755 --- a/bin/node-lambda +++ b/bin/node-lambda @@ -25,7 +25,7 @@ var AWS_MEMORY_SIZE = process.env.AWS_MEMORY_SIZE || 128; var AWS_TIMEOUT = process.env.AWS_TIMEOUT || 60; var AWS_RUN_TIMEOUT = process.env.AWS_RUN_TIMEOUT || 3; var AWS_DESCRIPTION = process.env.AWS_DESCRIPTION || packageJson.description || ''; -var AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs4.3'; +var AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs6.10'; var AWS_PUBLISH = process.env.AWS_PUBLISH || false; var AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION || ''; var AWS_VPC_SUBNETS = process.env.AWS_VPC_SUBNETS || ''; diff --git a/lib/.env.example b/lib/.env.example index dc9ed6c1..65305a4f 100644 --- a/lib/.env.example +++ b/lib/.env.example @@ -10,7 +10,7 @@ AWS_HANDLER=index.handler AWS_MEMORY_SIZE=128 AWS_TIMEOUT=3 AWS_DESCRIPTION= -AWS_RUNTIME=nodejs4.3 +AWS_RUNTIME=nodejs6.10 AWS_VPC_SUBNETS= AWS_VPC_SECURITY_GROUPS= EXCLUDE_GLOBS="event.json" diff --git a/lib/main.js b/lib/main.js index 852c876b..ccdd0372 100644 --- a/lib/main.js +++ b/lib/main.js @@ -74,37 +74,18 @@ Lambda.prototype._runHandler = function (handler, event, program, context) { } }; - var isNode43 = (program.runtime === "nodejs4.3"); - context.succeed = function (result) { - if (isNode43) { - console.log('context.succeed() is deprecated with Node.js 4.3 runtime'); - } - callback(null, result); - }; - context.fail = function (error) { - if (isNode43) { - console.log('context.fail() is deprecated with Node.js 4.3 runtime'); - } - callback(error); - }; - context.done = function () { - if (isNode43) { - console.log('context.done() is deprecated with Node.js 4.3 runtime'); - } - callback(); - }; context.getRemainingTimeInMillis = function () { var currentTime = new Date(); return timeout - (currentTime - startTime); }; switch(program.runtime) { - case "nodejs": - handler(event, context); - break; case "nodejs4.3": handler(event, context, callback); break; + case "nodejs6.10": + handler(event, context, callback); + break; default: console.error("Runtime [" + runtime + "] is not supported."); } diff --git a/test/main.js b/test/main.js index 2423e13f..eb351ae7 100644 --- a/test/main.js +++ b/test/main.js @@ -21,7 +21,7 @@ var originalProgram = { memorySize: 128, timeout: 3, description: '', - runtime: 'nodejs', + runtime: 'nodejs6.10', region: 'us-east-1,us-west-2,eu-west-1', eventFile: 'event.json', contextFile: 'context.json',