From 5e054b627736e83b816786eca76c4c25b4521d1e Mon Sep 17 00:00:00 2001 From: Aidan Casey Date: Mon, 22 Dec 2014 04:34:12 -0800 Subject: [PATCH] Making the Lambda timeout value configurable from grunt options file --- README.md | 24 +++++++++++++++++++++++- tasks/lambda_deploy.js | 6 ++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71c9ecf..e915f3b 100644 --- a/README.md +++ b/README.md @@ -341,6 +341,12 @@ Default value: `us-east-1` Specify the AWS region, useful if you'd normally operate in a certain region (such as one where Lambda isn't yet available) but wish to upload functions to another region. +##### options.timeout +Type: `Integer` +Default value: `null` +Depending on your Lambda function, you might need to increase the timeout value. The default timeout assigned by AWS is currently 3 seconds. + If you wish to increase this timeout set the value here. + #### Usage Examples ##### Default Options @@ -355,7 +361,23 @@ grunt.initConfig({ } }); ``` -And now if you run `grunt lambda_deploy` your package shoudl be created and uploaded to the specified function. +And now if you run `grunt lambda_deploy` your package should be created and uploaded to the specified function. + + +##### Increasing the Timeout Options to 10 seconds +In this example, the timeout value is increased to 10 seconds. + +```js +grunt.initConfig({ + lambda_deploy: { + default: { + function: 'my-lambda-function', + timeout : 10 + + } + } +}); +``` ## Misc info diff --git a/tasks/lambda_deploy.js b/tasks/lambda_deploy.js index 80e45b1..cd819ad 100644 --- a/tasks/lambda_deploy.js +++ b/tasks/lambda_deploy.js @@ -35,6 +35,7 @@ module.exports = function (grunt) { var deploy_function = grunt.config.get('lambda_deploy.' + this.target + '.function'); var deploy_package = grunt.config.get('lambda_deploy.' + this.target + '.package'); + var deploy_timeout = grunt.config.get('lambda_deploy.' + this.target + '.options.timeout'); AWS.config.update({region: options.region}); @@ -62,6 +63,11 @@ module.exports = function (grunt) { Runtime: current.Runtime }; + if (deploy_timeout !== null) + { + params.Timeout = deploy_timeout; + } + grunt.log.writeln('Uploading...'); fs.readFile(deploy_package, function (err, data) { params['FunctionZip'] = data;