-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (21 loc) · 753 Bytes
/
Copy pathindex.js
File metadata and controls
21 lines (21 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
// lambdash - AWS Lambda function to run shell commands
//
// See also: https://alestic.com/2014/11/aws-lambda-shell/
//
process.env['PATH'] = process.env['PATH'] + ':' + process.cwd()
var AWS = require('aws-sdk');
var exec = require('child_process').exec;
var MAX_OUTPUT = 1024 * 1024 * 1024; // 1 GB
exports.handler = function(event, context) {
var child = exec(event.command, {encoding: 'binary', maxBuffer: MAX_OUTPUT},
function (error, stdout, stderr) {
var result = {
"stdout": new Buffer(stdout, 'binary').toString('base64'),
"stderr": new Buffer(stderr, 'binary').toString('base64'),
"error": error
};
context.succeed(result);
}
);
}