1var AWS = require('aws-sdk');
2AWS.config.region = 'eu-west-1';
3var lambda = new AWS.Lambda();
4
5exports.handler = function(event, context) {
6 var params = {
7 FunctionName: 'Lambda_B', // the lambda function we are going to invoke
8 InvocationType: 'RequestResponse',
9 LogType: 'Tail',
10 Payload: '{ "name" : "Alex" }'
11 };
12
13 lambda.invoke(params, function(err, data) {
14 if (err) {
15 context.fail(err);
16 } else {
17 context.succeed('Lambda_B said '+ data.Payload);
18 }
19 })
20};
21
1// first install serverless
2$ npm install -g serverless
3// create basic template
4$ serverless create --template aws-nodejs --name candidate
5// configure aws and genrate client id and client secret
6serverless config credentials --provider aws --key <your_access_key_id> --secret <your_access_key_secret>
7 // deploy
8 serverless deploy