From 726a2d72e0495f671fe56e784a305081fe75df94 Mon Sep 17 00:00:00 2001 From: Joscha Probst Date: Wed, 12 Oct 2016 13:31:28 +0200 Subject: [PATCH 1/2] Added option for increasing the connection timeout of the aws-sdk in deploy step --- README.md | 1 + bin/node-lambda | 2 ++ lib/main.js | 4 ++++ test/main.js | 1 + 4 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 21c78dba..3e0e6b3c 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ $ node-lambda deploy --help -A, --packageDirectory [] Local package directory -x, --excludeGlobs [] Add a space separated list of file(type)s to ignore (e.g. "*.json .env") -D, --prebuiltDirectory [] Prebuilt directory + -T, --deployTimeout [120000] Deploy Timeout ``` ## Custom Environment Variables diff --git a/bin/node-lambda b/bin/node-lambda index d1bba065..d779e3cf 100755 --- a/bin/node-lambda +++ b/bin/node-lambda @@ -33,6 +33,7 @@ var EVENT_FILE = process.env.EVENT_FILE || 'event.json'; var PACKAGE_DIRECTORY = process.env.PACKAGE_DIRECTORY; var CONTEXT_FILE = process.env.CONTEXT_FILE || 'context.json'; var PREBUILT_DIRECTORY = process.env.PREBUILT_DIRECTORY || ''; +var DEPLOY_TIMEOUT = process.env.DEPLOY_TIMEOUT || 120000; program .command('deploy') @@ -63,6 +64,7 @@ program .option('-x, --excludeGlobs [' + EXCLUDE_GLOBS + ']', 'Space-separated glob pattern(s) for additional exclude files (e.g. "event.json dotenv.sample")', EXCLUDE_GLOBS) .option('-D, --prebuiltDirectory [' + PREBUILT_DIRECTORY + ']', 'Prebuilt directory', PREBUILT_DIRECTORY) + .option('-T, --deployTimeout [' + DEPLOY_TIMEOUT + ']', 'Deploy Timeout', DEPLOY_TIMEOUT) .action(function (prg) { lambda.deploy(prg); }); diff --git a/lib/main.js b/lib/main.js index 15fd094f..d0dd52eb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -494,6 +494,10 @@ Lambda.prototype.deploy = function (program) { aws_security.sessionToken = program.sessionToken; } + if (program.deployTimeout) { + aws.config.httpOptions.timeout = program.deployTimeout; + } + aws.config.update(aws_security); var lambda = new aws.Lambda({ diff --git a/test/main.js b/test/main.js index 9feb9342..b2b218bf 100644 --- a/test/main.js +++ b/test/main.js @@ -25,6 +25,7 @@ var originalProgram = { region: 'us-east-1,us-west-2,eu-west-1', eventFile: 'event.json', contextFile: 'context.json', + deployTimeout: 120000, prebuiltDirectory: '', }; From 3edaf657c63be3000f70678e59cdd69871310c1a Mon Sep 17 00:00:00 2001 From: Joscha Probst Date: Wed, 12 Oct 2016 13:50:03 +0200 Subject: [PATCH 2/2] added parseInt to ensure timeout is an integer --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index d0dd52eb..87142df0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -495,7 +495,7 @@ Lambda.prototype.deploy = function (program) { } if (program.deployTimeout) { - aws.config.httpOptions.timeout = program.deployTimeout; + aws.config.httpOptions.timeout = parseInt(program.deployTimeout); } aws.config.update(aws_security);