1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Cognitoのユーザ全部消す

Posted at

これはなに

Cognitoのユーザプールの中に登録されているユーザを全部クリアする方法です。
一発で実施する方法を探してみつからなかったので載せています、知ってる方は教えてください。

普通ユーザ全消しオペレーションはしないので、それなりに時間はかかります。

前提

  1. 要AWS CLIのインストール及びクレデンシャルの設定
  2. 要jq (いらない方法もあったはず・・)
#!/bin/bash

USER_POOL_ID=ap-northeast-1_xxxxxxxxx

 aws cognito-idp list-users --user-pool-id $USER_POOL_ID > prod_userpooluser_list.json
usernames=`jq -r .Users[].Username prod_userpooluser_list.json`

for username in $usernames; do
  aws cognito-idp admin-delete-user --user-pool-id $USER_POOL_ID --username $username
done

何をしているのかの解説

shell上では2回AWS CLIを実行しています。

前者

ユーザプールから全ユーザを抜き出しています

後者

抜き出したユーザのsub(UUID)を1件ずつ消しています。

以上です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?