diff --git a/README.md b/README.md index 6078313..147af3c 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,11 @@ module.exports = { EventSourceArn: , BatchSize: 200, StartingPosition: "TRIM_HORIZON" + }, + environment: { // optional + Variables: { + someKey: 'STRING_VALUE' + } } } ```` diff --git a/index.js b/index.js index 773f76d..9b476ac 100644 --- a/index.js +++ b/index.js @@ -39,6 +39,7 @@ exports.deploy = function(codePackage, config, callback, logger, lambda) { MemorySize: config.memorySize }; if (config.vpc) params.VpcConfig = config.vpc; + if (config.environment) params.Environment = config.environment; var isPublish = (config.publish === true); var updateEventSource = function(eventSource, callback) { diff --git a/test/all.js b/test/all.js index 71e909b..f5fb789 100644 --- a/test/all.js +++ b/test/all.js @@ -36,6 +36,11 @@ describe('node aws lambda module', function() { EventSourceArn: "arn:aws:kinesis:us-east-1:xxx:stream/KinesisStream-x0", BatchSize: 200, StartingPosition: "TRIM_HORIZON" + }, + environment: { + Variables: { + SOME_KEY: 'SOME_VALUE' + } } }; @@ -89,6 +94,11 @@ describe('node aws lambda module', function() { VpcConfig: { SecurityGroupIds: ['sg-xxxxxxx1', 'sg-xxxxxxx2'], SubnetIds: ['subnet-xxxxxxxx'] + }, + Environment: { + Variables: { + SOME_KEY: 'SOME_VALUE' + } } }); expect(data.Code.Content.toString()).to.equal(fs.readFileSync(packageV1).toString()); @@ -118,12 +128,18 @@ describe('node aws lambda module', function() { newConfig.vpc = { SecurityGroupIds: ['sg-xxxxxxx3'], SubnetIds: ['subnet-xxxxxxx1','subnet-xxxxxxx2'] - } + }; newConfig.eventSource = { EventSourceArn: "arn:aws:kinesis:us-east-1:xxx:stream/KinesisStream-x0", BatchSize: 50, StartingPosition: "LATEST" }; + newConfig.environment = { + Variables: { + SOME_KEY: 'SOME_CHANGED_VALUE', + SOME_NEW_KEY: 'SOME_NEW_VALUE' + } + } deploy(packageV2, newConfig, callback); }, @@ -145,6 +161,12 @@ describe('node aws lambda module', function() { VpcConfig: { SecurityGroupIds: ['sg-xxxxxxx3'], SubnetIds: ['subnet-xxxxxxx1', 'subnet-xxxxxxx2'] + }, + Environment: { + Variables: { + SOME_KEY: 'SOME_CHANGED_VALUE', + SOME_NEW_KEY: 'SOME_NEW_VALUE' + } } }); diff --git a/test/fake-lambda-service.js b/test/fake-lambda-service.js index cee6a9e..e879515 100644 --- a/test/fake-lambda-service.js +++ b/test/fake-lambda-service.js @@ -50,7 +50,7 @@ module.exports = function() { createFunction: function(params, callback) { validateParams(params, ['FunctionName', 'Code', 'Handler', 'Role', 'Runtime'], - ['Description', 'MemorySize', 'Timeout', 'Publish', 'VpcConfig'], 'createFunction') + ['Description', 'MemorySize', 'Timeout', 'Publish', 'VpcConfig', 'Environment'], 'createFunction') var name = params.FunctionName; var code = params.Code; @@ -154,7 +154,7 @@ module.exports = function() { updateFunctionConfiguration: function(params, callback) { validateParams(params, ['FunctionName'], - ['Description', 'Handler', 'MemorySize', 'Role', 'Timeout', 'VpcConfig'], + ['Description', 'Handler', 'MemorySize', 'Role', 'Timeout', 'VpcConfig', 'Environment'], 'updateFunctionConfiguration') var fun = getFun(params.FunctionName);