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

Added 'runtime' option #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Default value: None - Required (if you havn't specified an ARN)

##### Proxy
On Linux based hosts you can set proxy server for deploy task by specifying standard environment variable - https_proxy.
E.g:
E.g:
env https_proxy=http://localhost:8080 grunt deploy

##### package
Expand Down Expand Up @@ -382,6 +382,12 @@ Default value: `null`

Sets the handler for your lambda function. If left null, the current setting will remain unchanged.

##### options.runtime
Type: `String`
Default value: `null`

Sets the runtime for your lambda function. If left null, the current setting will remain unchanged.

##### options.enableVersioning
Type: `boolean`
Default value: `false`
Expand Down Expand Up @@ -469,6 +475,23 @@ grunt.initConfig({
});
```

##### Updating the Node.js runtime from 0.10 to 0.43
In this example, an existing lambda function is updated to use the new
Node.js 4.3 runtime (replacing the 0.10 runtime which is deprecated).

```js
grunt.initConfig({
lambda_deploy: {
default: {
arn: 'arn:aws:lambda:us-east-1:123456781234:function:my-function',
options: {
runtime: "nodejs4.3"
}
}
}
});
```

##### Example with a beta and prod deployment configuration

Deploy to beta with `deploy` and to prod with `deploy_prod`:
Expand Down Expand Up @@ -643,4 +666,4 @@ Adding more warnings for various failure cases

* Added support for Node 4.3 runtime callback function - [pull request by bobhigs](https://github.com/Tim-B/grunt-aws-lambda/pull/76)
* Added VPC support - [pull request by beeva-arturomartinez](https://github.com/Tim-B/grunt-aws-lambda/pull/71)
* Added local proxy support - [pull request by alekstr](https://github.com/Tim-B/grunt-aws-lambda/pull/66)
* Added local proxy support - [pull request by alekstr](https://github.com/Tim-B/grunt-aws-lambda/pull/66)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"mkdirp": "~0.5.0",
"rimraf": "~2.2.8",
"glob": "~4.3.0",
"aws-sdk": "~2.2.32",
"aws-sdk": "~2.29.0",
"proxy-agent": "latest",
"npm": "^2.10.0",
"q": "^1.4.1"
Expand Down
29 changes: 26 additions & 3 deletions test/unit/deploy_task_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ deployTaskTest.setUp = function(done) {
Configuration: {
timeout: 100,
MemorySize: 128,
Handler: 'handler'
Handler: 'handler',
Runtime: 'nodejs4.3'
}
}
}),
Expand All @@ -82,7 +83,7 @@ deployTaskTest.setUp = function(done) {
return lambdaAPIMock;
}
};

proxyAgentMock = sinon.spy();

fsMock.reset();
Expand All @@ -91,7 +92,7 @@ deployTaskTest.setUp = function(done) {
fsMock.setFileContent('some-package.zip', 'abc123');

mockery.registerMock('aws-sdk', awsSDKMock);

mockery.registerMock('proxy-agent', proxyAgentMock);

var dateFacadeMock = {
Expand Down Expand Up @@ -387,6 +388,28 @@ deployTaskTest.testHandler = function(test) {
gruntMock.execute(deployTask.getHandler, harnessParams);
};

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

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

var harnessParams = {
options: {
runtime: 'some-runtime'
},
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({Runtime: 'some-runtime'}));
test.done();
}
};
gruntMock.execute(deployTask.getHandler, harnessParams);
};

deployTaskTest.testEnableVersioning = function(test) {
test.expect(5);

Expand Down
7 changes: 6 additions & 1 deletion utils/deploy_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ deployTask.getHandler = function (grunt) {
timeout: null,
memory: null,
handler: null,
runtime: null,
enableVersioning: false,
aliases: null,
enablePackageVersionAlias: false,
subnetIds: null,
securityGroupIds: null
});

if (options.profile !== null) {
var credentials = new AWS.SharedIniFileCredentials({profile: options.profile});
AWS.config.credentials = credentials;
Expand Down Expand Up @@ -149,6 +150,10 @@ deployTask.getHandler = function (grunt) {
configParams.Handler = options.handler;
}

if (options.runtime !== null) {
configParams.Runtime = options.runtime;
}

if (options.subnetIds !== null && options.securityGroupIds !== null) {
configParams.VpcConfig = {
SubnetIds : options.subnetIds,
Expand Down