Skip to content

Commit

Permalink
Merge pull request #3 from aidancasey/master
Browse files Browse the repository at this point in the history
Making the Lambda timeout value configurable from grunt options file
  • Loading branch information
Tim-B committed May 23, 2015
2 parents 19e4195 + 5e054b6 commit 07f6254
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions tasks/lambda_deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 07f6254

Please sign in to comment.