Skip to content

Instantly share code, notes, and snippets.

@yodeah
Created January 19, 2017 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yodeah/e5f3a33547ab8e291f70e47f916081ec to your computer and use it in GitHub Desktop.
Save yodeah/e5f3a33547ab8e291f70e47f916081ec to your computer and use it in GitHub Desktop.
const CONF = require("./conf.json");
const AWS = require("aws-sdk");
var lambda = {};
function init(){
AWS.config = new AWS.Config({
accessKeyId:CONF.ID,
secretAccessKey:CONF.SECRET,
region:"eu-central-1",
});
lambda = new AWS.Lambda();
runAFunctionOnLambda("hello_world", {
echo:"stuff_2_echo"
});
}
function runAFunctionOnLambda(fn_str, payload){
var settings = {
FunctionName:fn_str,
Payload:JSON.stringify(payload)
};
lambda.invoke(settings, handleResponse);
}
function handleResponse(err, response){
if(err){
console.log("error");
console.dir(err);
return;
}
var data = JSON.parse(response.Payload);
console.log(data);
}
init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment