Skip to content

Instantly share code, notes, and snippets.

@chrisdiana
Last active March 18, 2024 09:38
Show Gist options
  • Save chrisdiana/cc7464d0624885dace587b08ced052e4 to your computer and use it in GitHub Desktop.
Save chrisdiana/cc7464d0624885dace587b08ced052e4 to your computer and use it in GitHub Desktop.
Export AWS Cognito User Pool
# Export as Text Table
aws --region XXXXXXXXX cognito-idp list-users --user-pool-id XXXXXXXXXXXXX --output table > ~/users.txt
# Export as JSON
aws --region XXXXXXXXX cognito-idp list-users --user-pool-id XXXXXXXXXXXXX --output json > ~/users.json
# Export User Pool with more than 60 users (pagination)
aws --region XXXXXXXXX cognito-idp list-users --user-pool-id XXXXXXXXXXXXX --pagination-token INCREDIBLYLONGSTRINGHERE --output json > ~/users-2.json
@mikhael28
Copy link

mikhael28 commented Aug 29, 2018

This was money! It didn't export all the users in the user pool, but it was a good start! Cognito's ListUserAPI has a default limit of 60 accounts to list at a time, however it does give you a 'PaginationToken' which you can re-insert into the following CLI request, and export to a different file - user1.txt for example.

After the --user-pool-id, add in --pagination-token INCREDIBLYLONGSTRINGHERE --output.... as usual until you export all your users.

@chrisdiana
Copy link
Author

Thanks @mikhael28! I'll add this above.

@diplodata
Copy link

Not sure that INCREDIBLYLONGSTRINGHERE sufficiently conveys how long those strings are

@striderwhite
Copy link

This was exactly what I was looking for! Huge ups!

@sprobst
Copy link

sprobst commented Sep 29, 2020

Also, the limit of 60 users seems to be gone. I exported 171 moments ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment