Skip to content

Instantly share code, notes, and snippets.

@ThisIsMissEm
Created November 25, 2014 18:53
Show Gist options
  • Star 58 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save ThisIsMissEm/d1c456d4e235e025791d to your computer and use it in GitHub Desktop.
Save ThisIsMissEm/d1c456d4e235e025791d to your computer and use it in GitHub Desktop.
The better way to execute Go on Amazon Lambda (see: http://blog.0x82.com/2014/11/24/aws-lambda-functions-in-go/)
var child_process = require('child_process');
exports.handler = function(event, context) {
var proc = spawn('./test', [ JSON.stringify(event) ], { stdio: 'inherit' });
proc.on('close', function(code){
if(code !== 0) {
return context.done(new Error("Process exited with non-zero status code"));
}
context.done(null);
});
}
@arihantagarwal
Copy link

@escholtz: Yes.

@tmaiaroto
Copy link

This has been really helpful for me in learning how to do this, thanks for sharing. I also stumbled upon an even better way: https://github.com/jasonmoo/lambda_proc

@yvele
Copy link

yvele commented Oct 25, 2016

You can now run vanilla Go on AWS Lambda, in a fast (<5ms) and clean way (log/panic)
https://github.com/eawsy/aws-lambda-go @eawsy
This feels like native Go support.. with a single file 😍

PS: No Node.js wrapper (using Python) and cgo under the hood

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