Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

586
Views
AWS Cognito delete all users from a user pool

How can we delete all users from a specific user pool in AWS Cognito using AWS CLI?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

try with below:

aws cognito-idp list-users --user-pool-id $COGNITO_USER_POOL_ID |
jq -r '.Users | .[] | .Username' |
while read uname1; do
  echo "Deleting $uname1";
  aws cognito-idp admin-delete-user --user-pool-id $COGNITO_USER_POOL_ID --username $uname1;
done
over 4 years ago · Santiago Trujillo Report

0

Here is a bash version based on @ajilpm's batch script:

# deleteAllUsers.sh
COGNITO_USER_POOL_ID=$1

aws cognito-idp list-users --user-pool-id $COGNITO_USER_POOL_ID |
jq -r '.Users | .[] | .Username' |
while read user; do
  aws cognito-idp admin-delete-user --user-pool-id $COGNITO_USER_POOL_ID --username $user
  echo "$user deleted"
done

You must have jq installed and remember to make the script executable: chmod +x deleteAllUsers.sh.

The user pool id can be provided as a command line argument: ./deleteAllUsers.sh COGNITO_USER_POOL_ID.

over 4 years ago · Santiago Trujillo Report

0

I created a script to do it from Windows CMD if you have AWS Cli installed and configured, which will delete all the users page by page, so you need to run it till all users are removed.

You need to have JQ downloaded and its path added to system env path for the following to work.

---delete.bat---

@echo off setlocal

for /f "delims=" %%I in 
  ('aws cognito-idp list-users --user-pool-id  $COGNITO_USER_POOL_ID ^| 
    jq -r ".Users | .[] | .Username"')
do 
  (aws cognito-idp admin-delete-user --user-pool-id $COGNITO_USER_POOL_ID --username %%I 
   echo %%I deleted)

---delete.bat---

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!