AWS Cognito: list of users
AWS Cognito is a great tool to chop-off authentication from your app, with a lot of bonuses when it comes to single sign on and integration with existing directories, but the web console is lacking some basic user management functionalities. Things like deleting a user by username or send back the a temporary password email cannot be done through the UI and require a certain machinery via the aws cli.
Moreover, something as simple as getting the list of all users, is not trivial due to the fact that the API is paginated (sometimes you have to pay for the sake of scalability, isn't it :) ?).
Well, if you're lucky enough that your users fit into a single Excel file (order of thousands), then this script will come handy - it will dump all the users for a cognito pool to stdout in CSV format:
Note that the Cognito API is rate limited, so one should take some care to not flood it. The script above is conservatively limiting the calls to at most 1/sec, which also bounds the (minimum) run time - so if you have 10000 users it will take roughly 3 minutes. If you have more users or you really don't like coffee breaks, then you could throttle calls in batches (like 1 second every 3 calls), or try to tweak the other magic number, that is 60, which seems to be the max page limit to fetch data at the time of publishing.
Have a lot of Cognito fun!