Skip to content

Add VPC Support #71

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

Merged
merged 2 commits into from
May 31, 2016
Merged
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,20 @@ alias will be created, allowing you to keep the old alias available for backward

It is recommended that `enableVersioning` is also enabled when using this feature.

##### options.subnetIds
Type: `Array`
Default value: `null`

A list of one or more subnet IDs in your VPC.

##### options.securityGroupIds
Type: `Array`
Default value: `null`

A list of one or more security groups IDs in your VPC.

If your Lambda function accesses resources in a VPC you must provide at least one security group and one subnet ID. These must belong to the same VPC

#### Usage Examples

##### Default Options
Expand Down
6 changes: 3 additions & 3 deletions test/unit/date_facade_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ dateFacadeTest.testGetFormattedTimestamp = function(test) {
};

dateFacadeTest.testGetHumanReadableTimestamp = function(test) {
var fixedDate = new Date(2016, 1, 13, 14, 38, 13);
test.ok(dateFacade.getHumanReadableTimestamp(fixedDate).indexOf('Sat Feb 13 2016 14:38:13') > -1);
var fixedDate = new Date(2016, 2, 13, 14, 38, 13);
test.ok(dateFacade.getHumanReadableTimestamp(fixedDate).indexOf('Sun Mar 13 2016 14:38:13') > -1);
test.done();
};
module.exports = dateFacadeTest;
module.exports = dateFacadeTest;
28 changes: 27 additions & 1 deletion test/unit/deploy_task_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,32 @@ deployTaskTest.testMemorySize = function(test) {
gruntMock.execute(deployTask.getHandler, harnessParams);
};

deployTaskTest.testVpcConfig = function(test) {
test.expect(4);

var deployTask = require('../../utils/deploy_task');

var harnessParams = {
options: {
subnetIds: ['subnet-XXXXX'],
securityGroupIds: ['sg-XXXXXX']
},
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({VpcConfig: {
SubnetIds : ['subnet-XXXXX'],
SecurityGroupIds : ['sg-XXXXXX']
}}));
test.done();
}
};
gruntMock.execute(deployTask.getHandler, harnessParams);
};

deployTaskTest.testHandler = function(test) {
test.expect(4);

Expand Down Expand Up @@ -468,4 +494,4 @@ deployTaskTest.testMultipleAliases = function(test) {
gruntMock.execute(deployTask.getHandler, harnessParams);
};

module.exports = deployTaskTest;
module.exports = deployTaskTest;
13 changes: 11 additions & 2 deletions utils/deploy_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ deployTask.getHandler = function (grunt) {
handler: null,
enableVersioning: false,
aliases: null,
enablePackageVersionAlias: false
enablePackageVersionAlias: false,
subnetIds: null,
securityGroupIds: null
});

if (options.profile !== null) {
Expand Down Expand Up @@ -138,6 +140,13 @@ deployTask.getHandler = function (grunt) {
configParams.Handler = options.handler;
}

if (options.subnetIds !== null && options.securityGroupIds !== null) {
configParams.VpcConfig = {
SubnetIds : options.subnetIds,
SecurityGroupIds : options.securityGroupIds
};
}

var updateConfig = function (func_name, func_options) {
var deferred = Q.defer();
if (Object.keys(func_options).length > 0) {
Expand Down Expand Up @@ -264,4 +273,4 @@ deployTask.getHandler = function (grunt) {
};
};

module.exports = deployTask;
module.exports = deployTask;