Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 698f80a

Browse files
committed
first commit
0 parents  commit 698f80a

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
node_modules/

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# aws-lambda-gulp-tasks
2+
3+
Simply exposes the tasks from https://github.com/ThoughtWorksStudios/node-aws-lambda as gulp tasks
4+
5+
## Usage
6+
7+
npm install gulp --save-dev
8+
npm install run-sequence --save-dev
9+
npm install aws-lambda-gulp-tasks --save-dev
10+
11+
gulpfile.js :
12+
````js
13+
var gulp = require('gulp');
14+
var runSequence = require('run-sequence');
15+
require('aws-lambda-gulp-tasks')(gulp);
16+
17+
gulp.task('deploy', function(callback) {
18+
return runSequence(
19+
['clean'],
20+
['js', 'node-mods'],
21+
// ADD ANY FILE YOU WANT TO THE dist/ folder
22+
['zip'],
23+
['upload'],
24+
callback
25+
);
26+
});
27+
````
28+
29+
lambda-config.js :
30+
````js
31+
module.exports = {
32+
accessKeyId: <access key id>, // optional
33+
secretAccessKey: <secret access key>, // optional
34+
profile: <shared credentials profile name>, // optional for loading AWS credentials from custom profile
35+
region: 'us-east-1',
36+
handler: 'index.handler',
37+
role: <role arn>,
38+
functionName: <function name>,
39+
timeout: 10,
40+
memorySize: 128,
41+
eventSource: {
42+
EventSourceArn: <event source such as kinesis ARN>,
43+
BatchSize: 200,
44+
StartingPosition: "TRIM_HORIZON"
45+
}
46+
}
47+
````
48+
49+
In your repository :
50+
51+
$ gulp deploy
52+
53+
## Gulp tasks made available
54+
55+
* clean
56+
* js
57+
* node-mods
58+
* zip
59+
* upload
60+
61+
* deploy (the full process) is given in the example above (but customizable)

index.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
var gulp = require('gulp'),
3+
zip = require('gulp-zip'),
4+
del = require('del'),
5+
install = require('gulp-install'),
6+
awsLambda = require('node-aws-lambda'),
7+
path = require('path');
8+
9+
module.exports = function(gulp) {
10+
11+
gulp.task('clean', function(cb) {
12+
return del(['./dist', './dist.zip'], cb);
13+
});
14+
15+
gulp.task('js', function() {
16+
return gulp.src('index.js')
17+
.pipe(gulp.dest('dist/'));
18+
});
19+
20+
gulp.task('node-mods', function() {
21+
return gulp.src('./package.json')
22+
.pipe(gulp.dest('dist/'))
23+
.pipe(install({production: true}));
24+
});
25+
26+
gulp.task('zip', function() {
27+
return gulp.src(['dist/**/*', '!dist/package.json'])
28+
.pipe(zip('dist.zip'))
29+
.pipe(gulp.dest('./'));
30+
});
31+
32+
gulp.task('upload', function(callback) {
33+
awsLambda.deploy('./dist.zip', require( path.join(process.cwd(), "lambda-config.js") ), callback);
34+
});
35+
36+
};

package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "aws-lambda-gulp-tasks",
3+
"version": "1.0.0",
4+
"description": "Gulp tasks to deploy AWS lambdas",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/neyric/aws-lambda-gulp-tasks.git"
9+
},
10+
"keywords": [
11+
"aws",
12+
"lambda",
13+
"gulp"
14+
],
15+
"author": "Eric Abouaf <[email protected]>",
16+
"dependencies": {
17+
"aws-sdk": "^2.1.45",
18+
"del": "^2.0.0",
19+
"gulp": "^3.9.0",
20+
"gulp-install": "^0.5.0",
21+
"gulp-zip": "^3.0.2",
22+
"node-aws-lambda": "^0.1.5"
23+
}
24+
}

0 commit comments

Comments
 (0)