Skip to content

Instantly share code, notes, and snippets.

@KennethanCeyer
Last active January 21, 2016 16:46
Show Gist options
  • Save KennethanCeyer/08f3ed9fb15670eb156f to your computer and use it in GitHub Desktop.
Save KennethanCeyer/08f3ed9fb15670eb156f to your computer and use it in GitHub Desktop.
AWS Lambda isn't supporting "yum install command".
var fs = require('fs');
var url = require('url');
var https = require('https');
var exec = require('child_process').exec;
var simpleGit = require('simple-git')();
var archiver = require('archiver');
var token = '[Your GitHub OAuth Token]';
var file_name = './deploy';
var version = '122632';
exports.handler = function(event, context) {
console.log('VERSION: ', version);
console.log('start to download the ' + file_name + ' via github.');
var remote_url = 'https://' + token + ':[email protected]/[Your GitHub UserName]/[User GitHub Repo Url]';
var proc = exec('cd /tmp; rm -rf ./' + file_name, function(error, stdout, stderr) {
console.log('cleaning the deploy files are completed.');
var proc = exec('yum -y install git', function(error, stdout, stderr) {
console.log('complete to install the git.');
simpleGit
.clone(remote_url, file_name, function() {
console.log('git clone complete from the ' + remote_url);
var distzip = fs.createWriteStream(file_name + '.zip');
console.log('complete to create the deployment a zip file.');
var archive = archiver('zip');
distzip.on('close', function() {
console.log(file_name + ' compress done. ' + (archive.pointer() / 1024).toFixed(2) + 'KB');
});
archive.pipe(distzip);
console.log('start to compress the zip file.');
archive.bulk([
{
expand: true,
cwd: "./" + file_name,
src: ["./**/*"],
dot: true
}
]);
archive.finalize();
})
.outputHandler(function (command, stdout, stderr) {
stdout.pipe(process.stdout);
stderr.pipe(process.stderr);
console.log(stdout);
console.log(stderr);
});
process.stderr.write(stderr);
process.stdout.write(stdout);
console.log(stderr);
console.log(stdout);
});
});
};
@KennethanCeyer
Copy link
Author

Lambda Logs=============

Could not set cachedir: [Errno 30] Read-only file system: '/var/tmp/yum-sbx_user1068-zKf8dl'
You need to be root to perform this command.

/bin/sh: git: command not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment