Skip to content

Commit

Permalink
Merge pull request #1 from rassokhin-s/add-env-vars
Browse files Browse the repository at this point in the history
Add support for environment variables
  • Loading branch information
rassokhin-s authored May 18, 2017
2 parents 6fb35e1 + 73fa8c7 commit e8bd96f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ module.exports = {
memorySize: 128,
publish: true, // default: false,
runtime: 'nodejs4.3', // default: 'nodejs4.3',
env: {, // optionl
[<Environment key/values>]
},
vpc: { // optional
SecurityGroupIds: [<security group id>, ...],
SubnetIds: [<subnet id>, ...]
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ exports.deploy = function(codePackage, config, callback, logger, lambda) {
MemorySize: config.memorySize
};
if (config.vpc) params.VpcConfig = config.vpc;
if (config.env) params.Environment = { Variables: config.env };
var isPublish = (config.publish === true);

var updateEventSource = function(eventSource, callback) {
Expand Down
13 changes: 13 additions & 0 deletions test/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ describe('node aws lambda module', function() {
timeout: 10,
memorySize: 128,
publish: true,
env: {
MyEvnVar: 'helloworld var',
},
vpc: {
SecurityGroupIds: ['sg-xxxxxxx1', 'sg-xxxxxxx2'],
SubnetIds: ['subnet-xxxxxxxx']
Expand Down Expand Up @@ -86,6 +89,11 @@ describe('node aws lambda module', function() {
MemorySize: 128,
Publish: true,
Runtime: "nodejs4.3",
Environment: {
Variables : {
MyEvnVar: 'helloworld var'
}
},
VpcConfig: {
SecurityGroupIds: ['sg-xxxxxxx1', 'sg-xxxxxxx2'],
SubnetIds: ['subnet-xxxxxxxx']
Expand Down Expand Up @@ -142,6 +150,11 @@ describe('node aws lambda module', function() {
MemorySize: 128,
Publish: false,
Runtime: "nodejs4.3",
Environment: {
Variables: {
MyEvnVar: 'helloworld var',
},
},
VpcConfig: {
SecurityGroupIds: ['sg-xxxxxxx3'],
SubnetIds: ['subnet-xxxxxxx1', 'subnet-xxxxxxx2']
Expand Down
4 changes: 2 additions & 2 deletions test/fake-lambda-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e8bd96f

Please sign in to comment.