diff --git a/lib/main.js b/lib/main.js index 053085c3..3d8017e9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -597,6 +597,7 @@ Lambda.prototype.deploy = function (program) { 'FunctionName': params.FunctionName }, function (err) { if (err) { + // Function does not exist return _this._uploadNew(lambda, params, function(err, results) { if (err) { throw err; @@ -609,34 +610,35 @@ Lambda.prototype.deploy = function (program) { cb(null, results); }); }); - } else { - _this._listEventSourceMappings(lambda, { - 'FunctionName': params.FunctionName - }, function(err, existingEventSourceList) { - if (err) { - throw err; + } + + // Function exists + _this._listEventSourceMappings(lambda, { + 'FunctionName': params.FunctionName + }, function(err, existingEventSourceList) { + if (err) { + throw err; + } + return async.parallel([ + function(_callback) { + _this._uploadExisting(lambda, params, function(err, results) { + if (err) { + throw err; + } + console.log('=> Zip file(s) done uploading. Results follow: '); + console.log(results); + _callback(err, results); + }); + }, + function(_callback) { + _this._updateEventSources(lambda, params.FunctionName, existingEventSourceList, eventSourceList, function(err, results) { + _callback(err, results); + }); } - return async.parallel([ - function(_callback) { - _this._uploadExisting(lambda, params, function(err, results) { - if (err) { - throw err; - } - console.log('=> Zip file(s) done uploading. Results follow: '); - console.log(results); - _callback(err, results); - }) - }, - function(_callback) { - _this._updateEventSources(lambda, params.FunctionName, existingEventSourceList, eventSourceList, function(err, results) { - _callback(err, results) - }) - } - ], function(err, results) { - cb(err, results); - }); + ], function(err, results) { + cb(err, results); }); - } + }); }); }, function (err, results) { if (err) {