diff --git a/package.json b/package.json index aa9e517..9ca0ff9 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "mkdirp": "~0.5.0", "rimraf": "~2.2.8", "glob": "~4.3.0", - "aws-sdk": "~2.2.32", + "aws-sdk": "~2.7.5", "proxy-agent": "latest", "npm": "^2.10.0", "q": "^1.4.1" diff --git a/test/unit/deploy_task_test.js b/test/unit/deploy_task_test.js index d584f18..3b7141b 100644 --- a/test/unit/deploy_task_test.js +++ b/test/unit/deploy_task_test.js @@ -365,6 +365,36 @@ deployTaskTest.testVpcConfig = function(test) { gruntMock.execute(deployTask.getHandler, harnessParams); }; +deployTaskTest.testEnvironmentVariables = function(test) { + test.expect(4); + + var deployTask = require('../../utils/deploy_task'); + + var harnessParams = { + options: { + environmentVariables: { + "key-1": "value-1", + "key-2": "value-2" + } + }, + config: defaultGruntConfig, + callback: function(harness) { + test.equal(harness.status, true); + test.equal(harness.output.length, 3); + test.equal(harness.output[2], 'Config updated.'); + + test.ok(lambdaAPIMock.updateFunctionConfiguration.calledWithMatch({Environment: { + Variables: { + "key-1": "value-1", + "key-2": "value-2" + } + }})); + test.done(); + } + }; + gruntMock.execute(deployTask.getHandler, harnessParams); +}; + deployTaskTest.testHandler = function(test) { test.expect(4); diff --git a/utils/deploy_task.js b/utils/deploy_task.js index fd6c675..24e8821 100644 --- a/utils/deploy_task.js +++ b/utils/deploy_task.js @@ -39,9 +39,10 @@ deployTask.getHandler = function (grunt) { aliases: null, enablePackageVersionAlias: false, subnetIds: null, - securityGroupIds: null + securityGroupIds: null, + environmentVariables: null }); - + if (options.profile !== null) { var credentials = new AWS.SharedIniFileCredentials({profile: options.profile}); AWS.config.credentials = credentials; @@ -149,6 +150,12 @@ deployTask.getHandler = function (grunt) { configParams.Handler = options.handler; } + if (options.environmentVariables !== null) { + configParams.Environment = { + Variables: options.environmentVariables + }; + } + if (options.subnetIds !== null && options.securityGroupIds !== null) { configParams.VpcConfig = { SubnetIds : options.subnetIds,