This repository provides small examples of using Amazon Web Service's Lambda service with Alma use cases. Each example is self-contained and sits in its own directory in this repository.
On any machine with Node.js and Git installed, do the following:
- Clone this repository:
git clone https://github.com/jweisman/AWS-Lambda-POC.git
- In the relevant directory, install dependencies:
npm install
- If available, copy the
config-example.json
file toconfig.json
and replace the placeholder values.
alma_host
andalma_path
from the Alma API Getting Started Guideapi_key
from the Ex Libris Developer Network dashboard
- Test the application locally with a test script (see below)
- Package the application with the
node_modules
into a zip file - Upload the zip to a Lambda function previously-defined in AWS using the console or the CLI:
aws lambda update-function-code --function-name MyFunctionName --zip-file fileb://MyFunctionZip.zip
You can test the Lambda function locally using a script such as the one below:
// Our Lambda function fle is required
var myLambda = require('./index.js');
// The Lambda context "done" function is called when complete with/without error var context = {
done: function (err, result) {
console.log('------------');
console.log('Context done');
console.log(' error:', err);
console.log(' result:', result);
}
};
// Create an event if required for your function
var event = {
};
// Call the Lambda function
myLambda.handler(event, context);
The code for these samples is made available under the MIT license.