Skip to content

Instantly share code, notes, and snippets.

@mariokostelac
Created February 10, 2016 10:17
Show Gist options
  • Save mariokostelac/fa298beef7450b011c18 to your computer and use it in GitHub Desktop.
Save mariokostelac/fa298beef7450b011c18 to your computer and use it in GitHub Desktop.
Lambda with FS operations
var fs = require('fs');
var filename = "/tmp/test";
exports.handler = function(event, context) {
fs.writeFile(filename, JSON.stringify(context), function(err) {
if(err) {
return console.log(err);
}
fs.readFile(filename, function(err, data) {
if (err) {
throw err;
}
context.succeed(data.toString('utf8'));
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment