Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read paginated values since we now have more than 60 pools
The initial version of this script read the first 60 user pools. This is because this is a paginated API, with a max value of 60. However, we now have more than 60 pools, so the new pool that we were trying to create was not returned in that first batch of 60. ``` response = cognito_client.list_user_pools(MaxResults=59) nrelopenpath-prod-unc-ebike does not exist! Try again later. ``` ``` response = cognito_client.list_user_pools(MaxResults=59) nrelopenpath-prod-unc-ebike does not exist! Try again later. ``` Simply bumping up the max results doesn't work because of the server side limit ``` response = cognito_client.list_user_pools(MaxResults=61) botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the ListUserPools operation: 1 validation error detected: Value '61' at 'maxResults' failed to satisfy constraint: Member must have value less than or equal to 60 ``` Instead, we need to implement pagination (similar to https://stackoverflow.com/a/64698263) to read all the entries before we try to find the pool name. We still have < 100 pools so this is fine. But if we get to 10s of thousands of pools, we should switch to a more streaming appraoch in which we check the results on each page instead of concatenating everything. Testing done: ``` Received response with len(response["UserPools"])=60 and next_token=REDACTED Received response with len(response["UserPools"])=21 & next_token=None [email protected] not in user pool! Creating account... Account created! Sending welcome email. [email protected] not in user pool! Creating account... Account created! Sending welcome email. [email protected] not in user pool! Creating account... Account created! Sending welcome email. ```
- Loading branch information