Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for environment variables #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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