awslabs / aws-support-tools

Tools and sample code provided by AWS Premium Support.
https://aws.amazon.com/premiumsupport/
Apache License 2.0
1.46k stars 801 forks source link

Paginate ListFunctions calls to ensure all functions are found #199

Closed roblaks closed 2 years ago

roblaks commented 2 years ago

Issue #, if available: N/A

Description of changes: Existing script is expecting that list-functions cli will return all functions under the account. However, the cli may perform return partial results and include a NextToken to retrieve the next set of functions. This means that users may not be finding all functions and function versions when trying to identify whether an ENI is still in use.

This change pulls out the NextToken from the response and makes paginated calls until no valid NextToken is returned.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.