Created
September 29, 2015 01:56
-
-
Save jinman/21503b694b99d96fc04c to your computer and use it in GitHub Desktop.
LambdaToLambda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Loading event'); | |
var AWS = require('aws-sdk'); | |
exports.handler = function(event, context) { | |
console.log("Request received:\n", JSON.stringify(event)); | |
console.log("Context received:\n", JSON.stringify(context)); | |
var lambdaFunctionArn = "arn:aws:lambda:us-west-2:555818481905:function:ProcessDeviceData-iot-test-hack-event-1"; | |
var lambdaRegion = "us-west-2"; | |
var params = { | |
FunctionName: lambdaFunctionArn, | |
InvocationType: 'RequestResponse', | |
LogType: 'None', | |
Payload: JSON.stringify(payload) | |
}; | |
var lambda = new AWS.Lambda({ | |
region: lambdaRegion | |
}); | |
lambda.invoke(params, function(err, data) { | |
if (err) { | |
context.fail('ERROR:Invoking Lambda function: ' + err) | |
} else { | |
console.log('great success:' + JSON.stringify(data, null, ' ')); | |
context.succeed('SUCCESS') | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment