Skip to content

Commit 19e4195

Browse files
committed
Improving failure warnings
1 parent 56bcd89 commit 19e4195

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,4 @@ In lieu of a formal styleguide, take care to maintain the existing coding style.
432432
## Release History
433433
* 0.1.0 - Initial release
434434
* 0.2.0 - Adding some unit tests, refactoring deploy task into single task and converting tasks to multitasks
435+
* 0.3.0 - Adding more warnings for various failure cases

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "grunt-aws-lambda",
33
"description": "A grunt plugin to help develop AWS Lambda functions.",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"homepage": "https://github.com/Tim-B/grunt-aws-lambda",
66
"author": {
77
"name": "Tim-B",

tasks/lambda_deploy.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ module.exports = function (grunt) {
4444

4545
lambda.getFunction({FunctionName: deploy_function}, function (err, data) {
4646

47-
if (data === null)
48-
{
49-
grunt.fail.warn('Unable to find lambda function ' + deploy_function + ' , verify the lambda function name and AWS region are correct');
47+
if (err) {
48+
if(err.statusCode === 404) {
49+
grunt.fail.warn('Unable to find lambda function ' + deploy_function + ', verify the lambda function name and AWS region are correct.');
50+
} else {
51+
grunt.fail.warn('AWS API request failed, check your AWS credentials and permissions are correct.');
52+
}
5053
}
5154

52-
5355
var current = data.Configuration;
5456

5557
var params = {
@@ -64,6 +66,9 @@ module.exports = function (grunt) {
6466
fs.readFile(deploy_package, function (err, data) {
6567
params['FunctionZip'] = data;
6668
lambda.uploadFunction(params, function (err, data) {
69+
if (err) {
70+
grunt.fail.warn('Package upload failed, check you have iam:PassRole permissions.');
71+
}
6772
grunt.log.writeln('Package deployed.');
6873
done(true);
6974
});

tasks/lambda_package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = function (grunt) {
4747
var archive_name = pkg.name + '_' + file_version + '_' + time_string;
4848

4949

50-
npm.load([], function (er, npm) {
50+
npm.load([], function (err, npm) {
5151

5252
npm.config.set('loglevel', 'silent');
5353

0 commit comments

Comments
 (0)