Last active
May 15, 2020 13:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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