Is there a way to filter the result from list users api on multiple conditions. I want to get list of all users who have usernames from a list
import boto3
client = boto3.client('cognito-idp')
client.list_users(UserPoolId='us-east-1_123456789', AttributesToGet=['email'], Filter="username =\"user_name_1\"")the above code returns me only one username. Now if I want to get the same information for multiple usernames I cant seem to find a way to do it.
ex:
import boto3
usernames=['user_id1','user_id2']
client = boto3.client('cognito-idp')
client.list_users(UserPoolId='us-east-1_123456789', AttributesToGet=['email'], Filter="username =usernames") 2 Answers
Unfortunately not:
You can only filter by strict equality or starts-with; no wildcards or arrays.
That said, ListUsers does not seem to have an specific api-calling limit, so you would be able to call it multiple times in quick succession until you had processed all the usernames.
client.list_users() does have a limit of 60 users and this function is not pageable.
I faced a similar problem and created the filter-value that included element i of the list and contained the entire filter expression ahead of the actual function so that I was able to call that filter value within the function.
In the end, I looped over the filter-value that would adopt the new value of the lists element i.
1