Search code examples
amazon-cognitoaws-cli

How do I add a boolean OR to cognito-idp list-user's --filter option


Currently, I can get a user in the user pool by specifying their username like so:

aws cognito-idp list-users --user-pool-id  xxx --filter 'username="ABC"'

However, what do I do if I want to get both user "ABC" and user "DEF"? Is it possible to add a boolean OR to the filter string?

Something like

aws cognito-idp list-users --user-pool-id  xxx --filter 'username="ABC" or username="DEF"'

Solution

  • You can jmespath in the query parameter instead of --filter, the syntax for multiple values is

    [? expr1 || expr2] 
    

    So you can use

    aws cognito-idp list-users --user-pool-id  us-west-demo --query 'Users[?Username==`demo1` || Username==`demo2`]'
    

    AmazonCognito-list-users