Files
query-orchestration/cmd/cognito_test/mfa/creation.script.examples/list-cognito-users.sh
T
Jay Brown e544f08505 Merged in feature/cognito-mfa-1 (pull request #154)
DRAFT for mfa demo

* for mfa demo

* Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/cognito-mfa-1

* Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/cognito-mfa-1

* cleanup

* list cognito users

* Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/cognito-mfa-1
2025-06-10 17:01:30 +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'