From c6c80bb3cb2c4529dd4cd6f4e8625412e26c6132 Mon Sep 17 00:00:00 2001 From: ryanp Date: Tue, 11 Aug 2015 10:12:51 -0500 Subject: [PATCH] update existing function vs delete so there is no outage --- cli/lib/main.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cli/lib/main.js b/cli/lib/main.js index 52092227b..27e46d2fe 100755 --- a/cli/lib/main.js +++ b/cli/lib/main.js @@ -8,7 +8,6 @@ var aws = require('aws-sdk'), fs = require('fs'), os = require('os'), packageJson = require('./../package.json'), - path = require('path'), async = require('async'), zip = new require('node-zip')(), wrench = require('wrench'), @@ -204,29 +203,32 @@ JAWS.prototype.deploy = function (stage, functionDir) { lambda_arn = data; return cb(err, data); }); - } else { - + //Update instead of delete so there is no downtime /** - * Delete Existing & Create New Lambda Function + * Update existing (code and config) */ - console.log("\tDeleting existing Lambda function in " + stage + "..."); + console.log("\tUpdating existing Lambda function in " + stage + " with params:"); + console.log(params); - lambda.deleteFunction({ - FunctionName: lambda_config.FunctionName + lambda.updateFunctionCode({ + FunctionName: params.FunctionName, + ZipFile: buffer }, function (err, data) { - if (err) { return deferred.reject(err); } - console.log("\tRe-uploading your Lambda Function with params:"); - console.log(params); - - params.Code = {ZipFile: buffer}; - lambda.createFunction(params, function (err, data) { + lambda.updateFunctionConfiguration({ + FunctionName: params.FunctionName, + Description: params.Description, + Handler: params.Handler, + MemorySize: params.MemorySize, + Role: params.Role, + Timeout: params.Timeout + }, function (err, data) { return cb(err, data); }); });