This package lets you supply a list of JSON payloads to an AWS Lambda function, managing concurrency so that you do not exceed AWS concurrency limits.
npm install lambda-queue
-
Create an AWS credentials file and save as
aws.json
. eg.{ "accessKeyId": "***", "secretAccessKey": "***", "region": "***" }
-
Create a set of JSON payloads for your lambda function and save as an array of objects in
payloads.json
-
Use the package as follows:
// Load LambdaQueue class var LambdaQueue = require('lambda-queue'); // Load payloads var payloads = require("./payloads.json"); // Load AWS Config var awsConfigPath = __dirname + "/aws.json"; var queue = new LambdaQueue({ awsConfigPath: awsConfigPath, lambdaFunctionName: 'hello-world', payloads: payloads, // Expects Array concurrency: 20, onTick: counts => { // gets called every time a lambda function returns console.log(counts) }, onComplete: results => { // gets called once every lambda function has returned console.log(results) } });
Copyright © 2017 Alan Thomson as.thomson@gmail.com
This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See LICENSE for full details.