Skip to content

Instantly share code, notes, and snippets.

@tecmaverick
Last active May 15, 2020 13:59
Show Gist options
  • Save tecmaverick/efff355c86d1705af7f939f77c509626 to your computer and use it in GitHub Desktop.
Save tecmaverick/efff355c86d1705af7f939f77c509626 to your computer and use it in GitHub Desktop.
Lambda Function to list all lambda functions. Using marker to page the results
const AWS = require('aws-sdk')
const lam = new AWS.Lambda()
async function getLambdaFuntions(marker)
{
let promise = new Promise(function(resolve, reject) {
var records = [];
var result = {"records":records,"marker":marker}
var params = {MaxItems: 100, FunctionVersion: 'ALL'}
if(marker != null)
params.Marker = marker
lam.listFunctions(params, function(err, data) {
if(err)
reject(err)
data.Functions.forEach(element => result.records.push(element.FunctionName))
result.marker = data.NextMarker
resolve(result)
})
});
return promise
}
exports.handler = async (event, context) => {
var records = []
var marker = null
while(true)
{
result = await getLambdaFuntions(marker)
marker = result.marker
result.records.forEach(record => records.push(record))
if(result.marker == null)
break
}
console.log(records)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment