Files
query-orchestration/cmd/auth_related/mfa/creation.script.examples/list-cognito-users.sh
T
Jay Brown 6dccf494f8 Merged in feature/permit-policy-cleanup (pull request #210)
cleanup permit policies and correct documentation

* docs

* policy cleanup

* refactor

* Merge remote-tracking branch 'origin/feature/permit-policy-cleanup' into feature/permit-policy-cleanup

* docs and edits
2026-02-19 20:22:59 +00:00

22 lines
906 B
Bash
Executable File

#!/bin/bash
# For testing and demos. Lists all of the users in a given user pool and then formats
# them in one line per user format for use in permit.io import.
# AWS Configuration
AWS_REGION="us-east-2"
AWS_PROFILE="aarete"
LOG_FILE="user.list.log.txt"
# User Pool Configuration
USER_POOL_ID="us-east-2_21upuTkkT"
echo "Listing all users in user pool '$USER_POOL_ID'..." | tee -a "$LOG_FILE"
# List all users in the user pool (output is JSON by default)
aws cognito-idp list-users \
--region "$AWS_REGION" --profile "$AWS_PROFILE" \
--user-pool-id "$USER_POOL_ID" > userlist.json
# convert the json output to one line per user.
echo "username, email, phone, subject id"
cat userlist.json | jq -r '.Users[] | [.Username, (.Attributes[] | select(.Name == "email") | .Value), (.Attributes[] | select(.Name == "phone_number") | .Value), (.Attributes[] | select(.Name == "sub") | .Value)] | @csv'