Amazon Cognito でコマンドからユーザ登録およびパスワード設定を行う方法について調査した内容を備忘録として残しておく

方法

該当の AWS Console にログインして AWS Cloud Shell 上で以下のコマンドを実行する

実際のコード

  1. ユーザ登録

    –user-attributes は必要に応じて増やす
    ※「–message-action SUPPRESS」のオプションを付与することで対象ユーザへの通知を止めることが可能

    aws cognito-idp admin-create-user \
    --user-pool-id <<ユーザプール ID>> \
    --username <<E メールアドレス ※E メールアドレスをユーザ名に設定した場合>> \
    --user-attributes Name=email,Value=<<E メールアドレス>> \
    Name=email_verified,Value=TRUE \
    --message-action SUPPRESS
    
  2. パスワード設定

    –no-permanent は仮パスワード扱い
    ※「–permanent」オプションを付与で恒久パスワード扱いになる

    aws cognito-idp admin-set-user-password \
    --user-pool-id <<ユーザプール ID>> \
    --username <<ユーザ名 or sub>> \
    --password <<password>> \
    --no-permanent