A talk by Vladimir Šetka
The Software Engineering Department of billigflieger.de
$
'use strict';
console.log('Loading function');
exports.handler = (event, context, callback) => {
// event is our payload
console.log('first param', event.param1);
console.log('second param', event.param2);
// context provides extra information
console.log('', context);
// after we're done, we call the callback
callback(null, event.key1);
};
filename.js
package.json
node_modules/async
node_modules/async/lib
node_modules/async/lib/async.js
node_modules/async/package.json
aws lambda create-function \
--region eu-central-1 \
--function-name my-function \
--zip-file fileb://my-function.zip \
--role arn:aws:iam::472899049124:role/my-lambda-execution-role \
--handler filename.handler \
--runtime nodejs4.3
aws lambda update-function-code \
--function-name bas-ranking-lambda \
--zip-file fileb://bas-ranking-lambda.zip \
--publish
exports.handler = (event, context, callback) => {
let lib = require('myLib');
lib.do(event.params)
.then((res) => callback(null, res));
};
let aws = require('aws-sdk');
module.exports.do = (data) => {
aws.lambda(data);
};
let client;
if (config.rpc) {
client = require('./rpc.js');
} else if (config.lambda) {
client = require('./lambda.js');
}
client.do({ some: 'data' });