Currently AWS provides cognito users filtering only on some standard attributes as given in the following documentation https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html
This script helps to get a list of cognito users filtered on any attributes including custom attributes.
- Down files from the git repo or clone the project
- cd to the download location
- run npm i on the terminal to install the dependencies.
- run node cognito-lusers.js on terminal
Script will start showing command to run.
- AWS access token
- AWS secret key
- Region to query
- Cognito pool id
- Limit
- Attributes to query
node cognito-lusers.js lusers --accessKey <value>
--secretKey <value>
-r <region>
-id <cognito pool id>
-atr <attributeKey1,attributeKey2>
-l <limit>
- Attribute value
node cognito-lusers.js lusers --accessKey <value>
--secretKey <value>
-r <region>
-id <cognito pool id>
-atr <attributeKey>
-l <limit>
-v <value>
Example 1: If more than one attribute is provided as shown in the command 1 above, value data will not be considered. Filtered list will match the users having all given attributes.
Example 2: If one attribute is provided as shown in the command 2 above, value data will be considered if provided in the command.
This script output the result in a json file (output.json) at the current location of the project file.
Anyone can use this utility script without any restrictions and allowed to modify based on their need.