I'd like a lambda called GoalsFeed to invoke another lambda called Goals using AWS.Lambda. This seems to work, except for two things:
I'm not sure how to pass a header through to the target service.
The FunctionName is "myapp-goals-get" (aka Goals) but I want to go to a specific path on that service - the three paths shown below are all valid, but i'm wanting to specify the "../owner/123" path.
Below is my first crack at this, can someone help me modify this to pass "tenantid" as a header and to ensure that when "myapp-goals-get" is invoked, it sees itself as being invoked from the path with "../owner/123" ?
// fetch back all goals by userid
var lambda = new AWS.Lambda({
region: 'us-east-1'
});
var payload = {};
payload[ "userId" ] = "123";
payload[ "tenantid" ] = "1";
const params = {
FunctionName: 'myapp-goals-get',
InvocationType: "RequestResponse",
Payload: JSON.stringify(payload)
};
lambda.invoke( params, function(error, data) {
console.log( "data: %s", JSON.stringify( data ) );
if( error ) {
context.done( 'error', error );
}
else if( data.Payload )
{
context.succeed( data.Payload )
}
});
lambda.invoke()there are no HTTP elements in the request -- you are instructing the Lambda API to invoke the the function directly, with yourPayload-- and there can be nothing else in that request. There are really no headers, no path, just the incomingeventstructure, which here you are populating with the stringified contents ofpayload. Any sense of "headers" or "paths" on the other side depends entirely on how that other function interprets its incomingeventobject. Show code please.