このドキュメントはバージョン 1 の AWS CLI のみを対象としています。AWS CLI のバージョン 2 に関連するドキュメントについては、バージョン 2 用ユーザーガイドを参照してください。
AWS CLI を使用する Amazon Cognito ID プロバイダーの例
次のコード例は、Amazon Cognito ID プロバイダーで AWS Command Line Interface を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。
アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。
各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。
トピック
アクション
次のコード例は、add-custom-attributes
を使用する方法を示しています。
- AWS CLI
-
カスタム属性を追加するには
この例では、カスタム属性 CustomAttr1 をユーザープールに追加しています。これは文字列型のため、1 文字以上 15 文字以下にする必要があります。この値は必須ではありません。
コマンド:
aws cognito-idp add-custom-attributes --user-pool-id
us-west-2_aaaaaaaaa
--custom-attributes Name="CustomAttr1",AttributeDataType="String",DeveloperOnlyAttribute=false,Required=false,StringAttributeConstraints="{MinLength=1,MaxLength=15}"-
API の詳細については、「AWS CLI コマンドリファレンス」の「AddCustomAttributes
」を参照してください。
-
次のコード例は、admim-disable-user
を使用する方法を示しています。
- AWS CLI
-
ユーザーを無効にするには
この例では、ユーザー jane@example.com を無効にしています。
コマンド:
aws cognito-idp admin-disable-user --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdmimDisableUser
」を参照してください。
-
次の例は、admim-enable-user
を使用する方法を説明しています。
- AWS CLI
-
ユーザーを有効にするには
この例では、ユーザー名 jane@example.com を有効にしています。
コマンド:
aws cognito-idp admin-enable-user --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdmimEnableUser
」を参照してください。
-
次のコード例は、admin-add-user-to-group
を使用する方法を示しています。
- AWS CLI
-
ユーザーをグループに追加するには
この例では、MyGroup にユーザー Jane を追加しています。
コマンド:
aws cognito-idp admin-add-user-to-group --user-pool-id
us-west-2_aaaaaaaaa
--usernameJane
--group-nameMyGroup
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminAddUserToGroup
」を参照してください。
-
次の例は、admin-confirm-sign-up
を使用する方法を説明しています。
- AWS CLI
-
ユーザー登録を確認するには
この例では、ユーザー jane@example.com を確認しています。
コマンド:
aws cognito-idp admin-confirm-sign-up --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminConfirmSignUp
」を参照してください。
-
次のコード例は、admin-create-user
を使用する方法を示しています。
- AWS CLI
-
ユーザーを作成するには
次の
admin-create-user
の例では、指定された設定の E メールアドレスと電話番号のユーザーを作成しています。aws cognito-idp admin-create-user \ --user-pool-id
us-west-2_aaaaaaaaa
\ --usernamediego
\ --user-attributesName=email,Value=diego@example.com
Name=phone_number,Value="+15555551212" \ --message-actionSUPPRESS
出力:
{ "User": { "Username": "diego", "Attributes": [ { "Name": "sub", "Value": "7325c1de-b05b-4f84-b321-9adc6e61f4a2" }, { "Name": "phone_number", "Value": "+15555551212" }, { "Name": "email", "Value": "diego@example.com" } ], "UserCreateDate": 1548099495.428, "UserLastModifiedDate": 1548099495.428, "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD" } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminCreateUser
」を参照してください。
-
次の例は、admin-delete-user-attributes
を使用する方法を説明しています。
- AWS CLI
-
ユーザー属性を削除するには
この例では、ユーザー diego@example.com のカスタム属性 CustomAttr1 を削除しています。
コマンド:
aws cognito-idp admin-delete-user-attributes --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
--user-attribute-names"custom:CustomAttr1"
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminDeleteUserAttributes
」を参照してください。
-
次の例は、admin-delete-user
を使用する方法を説明しています。
- AWS CLI
-
ユーザーを削除するには
この例では、ユーザーを削除します。
コマンド:
aws cognito-idp admin-delete-user --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminDeleteUser
」を参照してください。
-
次のコード例は、admin-forget-device
を使用する方法を示しています。
- AWS CLI
-
デバイスの「記憶済み」状態を解除するには
この例では、ユーザー名 jane@example.com のデバイスの「記憶済み」状態を解除しています
コマンド:
aws cognito-idp admin-forget-device --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
--device-keyus-west-2_abcd_1234-5678
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminForgetDevice
」を参照してください。
-
次のコード例は、admin-get-device
を使用する方法を示しています。
- AWS CLI
-
デバイスを取得するには
この例では、ユーザー名 jane@example.com のデバイスを取得しています
コマンド:
aws cognito-idp admin-get-device --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
--device-keyus-west-2_abcd_1234-5678
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminGetDevice
」を参照してください。
-
次の例は、admin-get-user
を使用する方法を説明しています。
- AWS CLI
-
ユーザーを取得するには
この例では、ユーザー名 jane@example.com に関する情報を取得します。
コマンド:
aws cognito-idp admin-get-user --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
出力:
{ "Username": "4320de44-2322-4620-999b-5e2e1c8df013", "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD", "UserCreateDate": 1548108509.537, "UserAttributes": [ { "Name": "sub", "Value": "4320de44-2322-4620-999b-5e2e1c8df013" }, { "Name": "email_verified", "Value": "true" }, { "Name": "phone_number_verified", "Value": "true" }, { "Name": "phone_number", "Value": "+01115551212" }, { "Name": "email", "Value": "jane@example.com" } ], "UserLastModifiedDate": 1548108509.537 }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminGetUser
」を参照してください。
-
次のコード例は、admin-initiate-auth
を使用する方法を示しています。
- AWS CLI
-
認可を開始するには
この例では、ユーザー名 jane@example.com の ADMIN_NO_SRP_AUTH フローを使用して認可を開始します。
クライアントでは、サーバーベースの認証用のサインイン API (ADMIN_NO_SRP_AUTH) が有効になっている必要があります。
戻り値のセッション情報を使用して、admin-respond-to-auth-challenge を呼び出します。
コマンド:
aws cognito-idp admin-initiate-auth --user-pool-id
us-west-2_aaaaaaaaa
--client-id3n4b5urk1ft4fl3mg5e62d9ado
--auth-flowADMIN_NO_SRP_AUTH
--auth-parametersUSERNAME=jane@example.com,PASSWORD=password
出力:
{ "ChallengeName": "NEW_PASSWORD_REQUIRED", "Session": "SESSION", "ChallengeParameters": { "USER_ID_FOR_SRP": "84514837-dcbc-4af1-abff-f3c109334894", "requiredAttributes": "[]", "userAttributes": "{\"email_verified\":\"true\",\"phone_number_verified\":\"true\",\"phone_number\":\"+01xxx5550100\",\"email\":\"jane@example.com\"}" } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminInitiateAuth
」を参照してください。
-
次の例は、admin-list-devices
を使用する方法を説明しています。
- AWS CLI
-
ユーザーのデバイスを一覧表示するには
この例では、ユーザー名 jane@example.com のデバイスを一覧表示しています。
コマンド:
aws cognito-idp admin-list-devices --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminListDevices
」を参照してください。
-
次の例は、admin-list-groups-for-user
を使用する方法を説明しています。
- AWS CLI
-
ユーザーのグループを一覧表示するには
この例では、ユーザー名 jane@example.com のグループを一覧表示しています。
コマンド:
aws cognito-idp admin-list-groups-for-user --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
出力:
{ "Groups": [ { "Description": "Sample group", "Precedence": 1, "LastModifiedDate": 1548097827.125, "RoleArn": "arn:aws:iam::111111111111:role/SampleRole", "GroupName": "SampleGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "CreationDate": 1548097827.125 } ] }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminListGroupsForUser
」を参照してください。
-
次の例は、admin-list-user-auth-events
を使用する方法を説明しています。
- AWS CLI
-
ユーザーの承認イベントを一覧表示するには
この例では、ユーザー名 diego@example.com の承認イベントを一覧表示しています。
コマンド:
aws cognito-idp admin-list-user-auth-events --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminListUserAuthEvents
」を参照してください。
-
次のコード例は、admin-remove-user-from-group
を使用する方法を示しています。
- AWS CLI
-
グループからユーザーを削除するには
この例では、SampleGroup から jane@example.com を削除しています。
コマンド:
aws cognito-idp admin-remove-user-from-group --user-pool-id
us-west-2_aaaaaaaaa
--usernamejane@example.com
--group-nameSampleGroup
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminRemoveUserFromGroup
」を参照してください。
-
次のコード例は、admin-reset-user-password
を使用する方法を示しています。
- AWS CLI
-
ユーザーのパスワードをリセットするには
この例では、diego@example.com のパスワードをリセットしています。
コマンド:
aws cognito-idp admin-reset-user-password --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminResetUserPassword
」を参照してください。
-
次の例は、admin-set-user-mfa-preference
を使用する方法を説明しています。
- AWS CLI
-
ユーザーの MFA を設定するには
この例では、ユーザー名 diego@example.com の SMS MFA 設定を行っています。
コマンド:
aws cognito-idp admin-set-user-mfa-preference --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
--sms-mfa-settingsEnabled=false,PreferredMfa=false
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminSetUserMfaPreference
」を参照してください。
-
次の例は、admin-set-user-settings
を使用する方法を説明しています。
- AWS CLI
-
ユーザー設定を行うには
この例では、ユーザー名 diego@example.com の MFA 配信設定を EMAIL に設定しています。
コマンド:
aws cognito-idp admin-set-user-settings --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
--mfa-optionsDeliveryMedium=EMAIL
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminSetUserSettings
」を参照してください。
-
次のコード例は、admin-update-auth-event-feedback
を使用する方法を示しています。
- AWS CLI
-
認証イベントにフィードバックを提供するには
この例では、event-id で識別される承認イベントのフィードバック値を Valid に設定します。
コマンド:
aws cognito-idp admin-update-auth-event-feedback --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
--event-idc2c2cf89-c0d3-482d-aba6-99d78a5b0bfe
--feedback-valueValid
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminUpdateAuthEventFeedback
」を参照してください。
-
次のコード例は、admin-update-device-status
を使用する方法を示しています。
- AWS CLI
-
デバイスステータスを更新するには
この例では、device-key によって識別されるデバイスの記憶状態を not_remembered に設定しています。
コマンド:
aws cognito-idp admin-update-device-status --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
--device-keyxxxx
--device-remembered-statusnot_remembered
-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminUpdateDeviceStatus
」を参照してください。
-
次の例は、admin-update-user-attributes
を使用する方法を説明しています。
- AWS CLI
-
ユーザー属性を更新するには
この例では、ユーザー diego@example.com のカスタムユーザー属性 CustomAttr1 を更新しています。
コマンド:
aws cognito-idp admin-update-user-attributes --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
--user-attributes Name="custom:CustomAttr1",Value="Purple"-
API の詳細については、「AWS CLI コマンドリファレンス」の「AdminUpdateUserAttributes
」を参照してください。
-
次のコード例は、change-password
を使用する方法を示しています。
- AWS CLI
-
パスワードを変更するには
この例では、パスワードを変更しています。
コマンド:
aws cognito-idp change-password --previous-password
OldPassword
--proposed-passwordNewPassword
--access-tokenACCESS_TOKEN
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ChangePassword
」を参照してください。
-
次のコード例は、confirm-forgot-password
を使用する方法を示しています。
- AWS CLI
-
忘れたパスワードを確認するには
この例では、ユーザー名 diego@example.com が忘れたパスワードを確認しています。
コマンド:
aws cognito-idp confirm-forgot-password --client-id
3n4b5urk1ft4fl3mg5e62d9ado
--username=diego@example.com --passwordPASSWORD
--confirmation-codeCONF_CODE
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ConfirmForgotPassword
」を参照してください。
-
次のコード例は、confirm-sign-up
を使用する方法を示しています。
- AWS CLI
-
サインアップを確認するには
この例では、ユーザー名 diego@example.com のサインアップを確認します。
コマンド:
aws cognito-idp confirm-sign-up --client-id
3n4b5urk1ft4fl3mg5e62d9ado
--username=diego@example.com --confirmation-codeCONF_CODE
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ConfirmSignUp
」を参照してください。
-
次のコード例は、create-group
を使用する方法を示しています。
- AWS CLI
-
グループを作成するには
この例では、説明付きのグループを作成しています。
コマンド:
aws cognito-idp create-group --user-pool-id
us-west-2_aaaaaaaaa
--group-nameMyNewGroup
--description"New group."
出力:
{ "Group": { "GroupName": "MyNewGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "New group.", "LastModifiedDate": 1548270073.795, "CreationDate": 1548270073.795 } }
ロールと優先順位を持つグループを作成するには
この例では、説明付きのグループを作成しています。また、ロールと優先順位も含まれます。
コマンド:
aws cognito-idp create-group --user-pool-id
us-west-2_aaaaaaaaa
--group-nameMyNewGroupWithRole
--description"New group with a role."
--role-arnarn:aws:iam::111111111111:role/MyNewGroupRole
--precedence2
出力:
{ "Group": { "GroupName": "MyNewGroupWithRole", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "New group with a role.", "RoleArn": "arn:aws:iam::111111111111:role/MyNewGroupRole", "Precedence": 2, "LastModifiedDate": 1548270211.761, "CreationDate": 1548270211.761 } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateGroup
」を参照してください。
-
次の例は、create-user-import-job
を使用する方法を説明しています。
- AWS CLI
-
ユーザーインポートジョブを作成するには
この例では、MyImportJob という名前のユーザーインポートジョブを作成しています。
ユーザーをインポートする方法の詳細については、「Importing Users into User Pools From a CSV File」を参照してください。
コマンド:
aws cognito-idp create-user-import-job --user-pool-id
us-west-2_aaaaaaaaa
--job-nameMyImportJob
--cloud-watch-logs-role-arnarn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole
出力:
{ "UserImportJob": { "JobName": "MyImportJob", "JobId": "import-qQ0DCt2fRh", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548271795.471, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 } }
署名付き URL を使用して、.csv ファイルを curl でアップロードします。
コマンド:
curl -v -T "PATH_TO_CSV_FILE" -H "x-amz-server-side-encryption:aws:kms" "PRE_SIGNED_URL"
-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateUserImportJob
」を参照してください。
-
次の例は、create-user-pool-client
を使用する方法を説明しています。
- AWS CLI
-
ユーザープールのクライアントを作成するには
この例では、USER_PASSWORD_AUTH と ADMIN_NO_SRP_AUTH の 2 つの明示的な認証フローを持つ新しいユーザープールクライアントを作成しています。
コマンド:
aws cognito-idp create-user-pool-client --user-pool-id
us-west-2_aaaaaaaaa
--client-nameMyNewClient
--no-generate-secret --explicit-auth-flows"USER_PASSWORD_AUTH"
"ADMIN_NO_SRP_AUTH"
出力:
{ "UserPoolClient": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientName": "MyNewClient", "ClientId": "6p3bs000no6a4ue1idruvd05ad", "LastModifiedDate": 1548697449.497, "CreationDate": 1548697449.497, "RefreshTokenValidity": 30, "ExplicitAuthFlows": [ "USER_PASSWORD_AUTH", "ADMIN_NO_SRP_AUTH" ], "AllowedOAuthFlowsUserPoolClient": false } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateUserPoolClient
」を参照してください。
-
次のコード例は、create-user-pool-domain
を使用する方法を示しています。
- AWS CLI
-
ユーザープールのドメインを作成するには
この例では、USER_PASSWORD_AUTH と ADMIN_NO_SRP_AUTH の 2 つの明示的な承認フローを持つ新しいユーザープールのドメインを作成しています。
コマンド:
aws cognito-idp create-user-pool-domain --user-pool-id
us-west-2_aaaaaaaaa
--domainmy-new-domain
-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateUserPoolDomain
」を参照してください。
-
次のコード例は、create-user-pool
を使用する方法を示しています。
- AWS CLI
-
最小構成のユーザープールを作成するには
この例では、デフォルト値を使用して MyUserPool という名前のユーザープールを作成します。必要な属性やアプリケーションクライアントはありません。MFA およびアドバンストセキュリティは無効化されています。
コマンド:
aws cognito-idp create-user-pool --pool-name
MyUserPool
出力:
{ "UserPool": { "SchemaAttributes": [ { "Name": "sub", "StringAttributeConstraints": { "MinLength": "1", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": false }, { "Name": "name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "given_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "family_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "middle_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "nickname", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "preferred_username", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "profile", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "picture", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "website", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "email", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "email_verified", "Mutable": true }, { "Name": "gender", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "birthdate", "StringAttributeConstraints": { "MinLength": "10", "MaxLength": "10" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "zoneinfo", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "locale", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "phone_number", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "phone_number_verified", "Mutable": true }, { "Name": "address", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "updated_at", "NumberAttributeConstraints": { "MinValue": "0" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "Number", "Mutable": true } ], "MfaConfiguration": "OFF", "Name": "MyUserPool", "LastModifiedDate": 1547833345.777, "AdminCreateUserConfig": { "UnusedAccountValidityDays": 7, "AllowAdminCreateUserOnly": false }, "EmailConfiguration": {}, "Policies": { "PasswordPolicy": { "RequireLowercase": true, "RequireSymbols": true, "RequireNumbers": true, "MinimumLength": 8, "RequireUppercase": true } }, "CreationDate": 1547833345.777, "EstimatedNumberOfUsers": 0, "Id": "us-west-2_aaaaaaaaa", "LambdaConfig": {} } }
2 つの必須属性でユーザープールを作成するには
この例では、ユーザープール MyUserPool を作成します。プールは、E メールをユーザー名属性として受け入れるように設定されています。また、Amazon Simple Email Service を使用して、E メールの送信元アドレスを検証済みのアドレスに設定します。
コマンド:
aws cognito-idp create-user-pool --pool-name
MyUserPool
--username-attributes"email"
--email-configuration=SourceArn="arn:aws:ses:us-east-1:111111111111:identity/jane@example.com",ReplyToEmailAddress="jane@example.com"出力:
{ "UserPool": { "SchemaAttributes": [ { "Name": "sub", "StringAttributeConstraints": { "MinLength": "1", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": false }, { "Name": "name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "given_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "family_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "middle_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "nickname", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "preferred_username", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "profile", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "picture", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "website", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "email", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "email_verified", "Mutable": true }, { "Name": "gender", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "birthdate", "StringAttributeConstraints": { "MinLength": "10", "MaxLength": "10" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "zoneinfo", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "locale", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "phone_number", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "phone_number_verified", "Mutable": true }, { "Name": "address", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "updated_at", "NumberAttributeConstraints": { "MinValue": "0" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "Number", "Mutable": true } ], "MfaConfiguration": "OFF", "Name": "MyUserPool", "LastModifiedDate": 1547837788.189, "AdminCreateUserConfig": { "UnusedAccountValidityDays": 7, "AllowAdminCreateUserOnly": false }, "EmailConfiguration": { "ReplyToEmailAddress": "jane@example.com", "SourceArn": "arn:aws:ses:us-east-1:111111111111:identity/jane@example.com" }, "Policies": { "PasswordPolicy": { "RequireLowercase": true, "RequireSymbols": true, "RequireNumbers": true, "MinimumLength": 8, "RequireUppercase": true } }, "UsernameAttributes": [ "email" ], "CreationDate": 1547837788.189, "EstimatedNumberOfUsers": 0, "Id": "us-west-2_aaaaaaaaa", "LambdaConfig": {} } }
-
API の詳細については、AWS CLI コマンドリファレンスの「CreateUserPool
」を参照してください。
-
次の例は、delete-group
を使用する方法を説明しています。
- AWS CLI
-
グループを削除するには
この例では、グループを削除しています。
コマンド:
aws cognito-idp delete-group --user-pool-id
us-west-2_aaaaaaaaa
--group-nameMyGroupName
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteGroup
」を参照してください。
-
次のコード例は、delete-identity-provider
を使用する方法を示しています。
- AWS CLI
-
ID プロバイダーを削除するには
この例では、ID プロバイダーを削除しています。
コマンド:
aws cognito-idp delete-identity-provider --user-pool-id
us-west-2_aaaaaaaaa
--provider-nameFacebook
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteIdentityProvider
」を参照してください。
-
次の例は、delete-resource-server
を使用する方法を説明しています。
- AWS CLI
-
リソースサーバーを削除するには
この例では、weather.example.com という名前のリソースサーバーを削除しています。
コマンド:
aws cognito-idp delete-resource-server --user-pool-id
us-west-2_aaaaaaaaa
--identifierweather.example.com
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteResourceServer
」を参照してください。
-
次の例は、delete-user-attributes
を使用する方法を説明しています。
- AWS CLI
-
ユーザー属性を削除するには
この例では、ユーザー属性「FAVORITE_ANIMAL」を削除しています。
コマンド:
aws cognito-idp delete-user-attributes --access-token
ACCESS_TOKEN
--user-attribute-names"FAVORITE_ANIMAL"
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteUserAttributes
」を参照してください。
-
次の例は、delete-user-pool-client
を使用する方法を説明しています。
- AWS CLI
-
ユーザープールクライアントを削除するには
この例では、ユーザープールクライアントを削除しています。
コマンド:
aws cognito-idp delete-user-pool-client --user-pool-id
us-west-2_aaaaaaaaa
--client-id38fjsnc484p94kpqsnet7mpld0
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteUserPoolClient
」を参照してください。
-
次のコード例は、delete-user-pool-domain
を使用する方法を示しています。
- AWS CLI
-
ユーザープールのドメインを削除するには
次の
delete-user-pool-domain
の例では、my-domain
という名前のユーザープールのドメインを削除しています。aws cognito-idp delete-user-pool-domain \ --user-pool-id
us-west-2_aaaaaaaaa
\ --domainmy-domain
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteUserPoolDomain
」を参照してください。
-
次の例は、delete-user-pool
を使用する方法を説明しています。
- AWS CLI
-
ユーザープールを削除するには
この例では、ユーザープール ID、us-west-2_aaaaaaaaa を使用してユーザープールを削除しています。
コマンド:
aws cognito-idp delete-user-pool --user-pool-id
us-west-2_aaaaaaaaa
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteUserPool
」を参照してください。
-
次の例は、delete-user
を使用する方法を説明しています。
- AWS CLI
-
ユーザーを削除するには
この例では、ユーザーを削除します。
コマンド:
aws cognito-idp delete-user --access-token
ACCESS_TOKEN
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteUser
」を参照してください。
-
次のコード例は、describe-identity-provider
を使用する方法を示しています。
- AWS CLI
-
ID プロバイダーを記述するには
この例では、Facebook という名前の ID プロバイダーを記述します。
コマンド:
aws cognito-idp describe-identity-provider --user-pool-id
us-west-2_aaaaaaaaa
--provider-nameFacebook
出力:
{ "IdentityProvider": { "UserPoolId": "us-west-2_aaaaaaaaa", "ProviderName": "Facebook", "ProviderType": "Facebook", "ProviderDetails": { "attributes_url": "https://graph.facebook.com/me?fields=", "attributes_url_add_attributes": "true", "authorize_scopes": myscope", "authorize_url": "https://www.facebook.com/v2.9/dialog/oauth", "client_id": "11111", "client_secret": "11111", "token_request_method": "GET", "token_url": "https://graph.facebook.com/v2.9/oauth/access_token" }, "AttributeMapping": { "username": "id" }, "IdpIdentifiers": [], "LastModifiedDate": 1548105901.736, "CreationDate": 1548105901.736 } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DescribeIdentityProvider
」を参照してください。
-
次の例は、describe-resource-server
を使用する方法を説明しています。
- AWS CLI
-
リソースサーバーを記述するには
この例では、リソースサーバー weather.example.com を記述します。
コマンド:
aws cognito-idp describe-resource-server --user-pool-id
us-west-2_aaaaaaaaa
--identifierweather.example.com
出力:
{ "ResourceServer": { "UserPoolId": "us-west-2_aaaaaaaaa", "Identifier": "weather.example.com", "Name": "Weather", "Scopes": [ { "ScopeName": "weather.update", "ScopeDescription": "Update weather forecast" }, { "ScopeName": "weather.read", "ScopeDescription": "Read weather forecasts" }, { "ScopeName": "weather.delete", "ScopeDescription": "Delete a weather forecast" } ] } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DescribeResourceServer
」を参照してください。
-
次のコード例は、describe-risk-configuration
を使用する方法を示しています。
- AWS CLI
-
リスク設定を記述するには
この例では、プール us-west-2_aaaaaaaa に関連するリスク設定を記述します。
コマンド:
aws cognito-idp describe-risk-configuration --user-pool-id
us-west-2_aaaaaaaaa
出力:
{ "RiskConfiguration": { "UserPoolId": "us-west-2_aaaaaaaaa", "CompromisedCredentialsRiskConfiguration": { "EventFilter": [ "SIGN_IN", "SIGN_UP", "PASSWORD_CHANGE" ], "Actions": { "EventAction": "BLOCK" } }, "AccountTakeoverRiskConfiguration": { "NotifyConfiguration": { "From": "diego@example.com", "ReplyTo": "diego@example.com", "SourceArn": "arn:aws:ses:us-east-1:111111111111:identity/diego@example.com", "BlockEmail": { "Subject": "Blocked sign-in attempt", "HtmlBody": "<!DOCTYPE html>\n<html>\n<head>\n\t<title>HTML email context</title>\n\t<meta charset=\"utf-8\">\n</head>\n<body>\n<pre>We blocked an unrecognized sign-in to your account with this information:\n<ul>\n<li>Time: {login-time}</li>\n<li>Device: {device-name}</li>\n<li>Location: {city}, {country}</li>\n</ul>\nIf this sign-in was not by you, you should change your password and notify us by clicking on <a href={one-click-link-invalid}>this link</a>\nIf this sign-in was by you, you can follow <a href={one-click-link-valid}>this link</a> to let us know</pre>\n</body>\n</html>", "TextBody": "We blocked an unrecognized sign-in to your account with this information:\nTime: {login-time}\nDevice: {device-name}\nLocation: {city}, {country}\nIf this sign-in was not by you, you should change your password and notify us by clicking on {one-click-link-invalid}\nIf this sign-in was by you, you can follow {one-click-link-valid} to let us know" }, "NoActionEmail": { "Subject": "New sign-in attempt", "HtmlBody": "<!DOCTYPE html>\n<html>\n<head>\n\t<title>HTML email context</title>\n\t<meta charset=\"utf-8\">\n</head>\n<body>\n<pre>We observed an unrecognized sign-in to your account with this information:\n<ul>\n<li>Time: {login-time}</li>\n<li>Device: {device-name}</li>\n<li>Location: {city}, {country}</li>\n</ul>\nIf this sign-in was not by you, you should change your password and notify us by clicking on <a href={one-click-link-invalid}>this link</a>\nIf this sign-in was by you, you can follow <a href={one-click-link-valid}>this link</a> to let us know</pre>\n</body>\n</html>", "TextBody": "We observed an unrecognized sign-in to your account with this information:\nTime: {login-time}\nDevice: {device-name}\nLocation: {city}, {country}\nIf this sign-in was not by you, you should change your password and notify us by clicking on {one-click-link-invalid}\nIf this sign-in was by you, you can follow {one-click-link-valid} to let us know" }, "MfaEmail": { "Subject": "New sign-in attempt", "HtmlBody": "<!DOCTYPE html>\n<html>\n<head>\n\t<title>HTML email context</title>\n\t<meta charset=\"utf-8\">\n</head>\n<body>\n<pre>We required you to use multi-factor authentication for the following sign-in attempt:\n<ul>\n<li>Time: {login-time}</li>\n<li>Device: {device-name}</li>\n<li>Location: {city}, {country}</li>\n</ul>\nIf this sign-in was not by you, you should change your password and notify us by clicking on <a href={one-click-link-invalid}>this link</a>\nIf this sign-in was by you, you can follow <a href={one-click-link-valid}>this link</a> to let us know</pre>\n</body>\n</html>", "TextBody": "We required you to use multi-factor authentication for the following sign-in attempt:\nTime: {login-time}\nDevice: {device-name}\nLocation: {city}, {country}\nIf this sign-in was not by you, you should change your password and notify us by clicking on {one-click-link-invalid}\nIf this sign-in was by you, you can follow {one-click-link-valid} to let us know" } }, "Actions": { "LowAction": { "Notify": true, "EventAction": "NO_ACTION" }, "MediumAction": { "Notify": true, "EventAction": "MFA_IF_CONFIGURED" }, "HighAction": { "Notify": true, "EventAction": "MFA_IF_CONFIGURED" } } } } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DescribeRiskConfiguration
」を参照してください。
-
次の例は、describe-user-import-job
を使用する方法を説明しています。
- AWS CLI
-
ユーザーインポートジョブを記述するには
この例では、ユーザー入力ジョブを記述します。
ユーザーをインポートする方法の詳細については、「Importing Users into User Pools From a CSV File」を参照してください。
コマンド:
aws cognito-idp describe-user-import-job --user-pool-id
us-west-2_aaaaaaaaa
--job-idimport-TZqNQvDRnW
出力:
{ "UserImportJob": { "JobName": "import-Test1", "JobId": "import-TZqNQvDRnW", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED URL", "CreationDate": 1548271708.512, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DescribeUserImportJob
」を参照してください。
-
次の例は、describe-user-pool-client
を使用する方法を説明しています。
- AWS CLI
-
ユーザープールクライアントを記述するには
この例では、ユーザープールクライアントを記述します。
コマンド:
aws cognito-idp describe-user-pool-client --user-pool-id
us-west-2_aaaaaaaaa
--client-id38fjsnc484p94kpqsnet7mpld0
出力:
{ "UserPoolClient": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientName": "MyApp", "ClientId": "38fjsnc484p94kpqsnet7mpld0", "ClientSecret": "CLIENT_SECRET", "LastModifiedDate": 1548108676.163, "CreationDate": 1548108676.163, "RefreshTokenValidity": 30, "ReadAttributes": [ "address", "birthdate", "custom:CustomAttr1", "custom:CustomAttr2", "email", "email_verified", "family_name", "gender", "given_name", "locale", "middle_name", "name", "nickname", "phone_number", "phone_number_verified", "picture", "preferred_username", "profile", "updated_at", "website", "zoneinfo" ], "WriteAttributes": [ "address", "birthdate", "custom:CustomAttr1", "custom:CustomAttr2", "email", "family_name", "gender", "given_name", "locale", "middle_name", "name", "nickname", "phone_number", "picture", "preferred_username", "profile", "updated_at", "website", "zoneinfo" ], "ExplicitAuthFlows": [ "ADMIN_NO_SRP_AUTH", "USER_PASSWORD_AUTH" ], "AllowedOAuthFlowsUserPoolClient": false } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DescribeUserPoolClient
」を参照してください。
-
次の例は、describe-user-pool-domain
を使用する方法を説明しています。
- AWS CLI
-
ユーザープールクライアントを記述するには
この例では、my-domain という名前のユーザープールドメインを記述します。
コマンド:
aws cognito-idp describe-user-pool-domain --domain
my-domain
出力:
{ "DomainDescription": { "UserPoolId": "us-west-2_aaaaaaaaa", "AWSAccountId": "111111111111", "Domain": "my-domain", "S3Bucket": "aws-cognito-prod-pdx-assets", "CloudFrontDistribution": "aaaaaaaaaaaaa.cloudfront.net", "Version": "20190128175402", "Status": "ACTIVE", "CustomDomainConfig": {} } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DescribeUserPoolDomain
」を参照してください。
-
次のコード例は、describe-user-pool
を使用する方法を示しています。
- AWS CLI
-
ユーザープールを記述するには
この例では、ユーザープール ID us-west-2_aaaaaaaaa を持つユーザープールを記述します。
コマンド:
aws cognito-idp describe-user-pool --user-pool-id
us-west-2_aaaaaaaaa
出力:
{ "UserPool": { "SmsVerificationMessage": "Your verification code is {####}. ", "SchemaAttributes": [ { "Name": "sub", "StringAttributeConstraints": { "MinLength": "1", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": false }, { "Name": "name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "given_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "family_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "middle_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "nickname", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "preferred_username", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "profile", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "picture", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "website", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "email", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "email_verified", "Mutable": true }, { "Name": "gender", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "birthdate", "StringAttributeConstraints": { "MinLength": "10", "MaxLength": "10" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "zoneinfo", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "locale", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "phone_number", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "phone_number_verified", "Mutable": true }, { "Name": "address", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "updated_at", "NumberAttributeConstraints": { "MinValue": "0" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "Number", "Mutable": true } ], "EmailVerificationSubject": "Your verification code", "MfaConfiguration": "OFF", "Name": "MyUserPool", "EmailVerificationMessage": "Your verification code is {####}. ", "SmsAuthenticationMessage": "Your authentication code is {####}. ", "LastModifiedDate": 1547763720.822, "AdminCreateUserConfig": { "InviteMessageTemplate": { "EmailMessage": "Your username is {username} and temporary password is {####}. ", "EmailSubject": "Your temporary password", "SMSMessage": "Your username is {username} and temporary password is {####}. " }, "UnusedAccountValidityDays": 7, "AllowAdminCreateUserOnly": false }, "EmailConfiguration": { "ReplyToEmailAddress": "myemail@mydomain.com" "SourceArn": "arn:aws:ses:us-east-1:000000000000:identity/myemail@mydomain.com" }, "AutoVerifiedAttributes": [ "email" ], "Policies": { "PasswordPolicy": { "RequireLowercase": true, "RequireSymbols": true, "RequireNumbers": true, "MinimumLength": 8, "RequireUppercase": true } }, "UserPoolTags": {}, "UsernameAttributes": [ "email" ], "CreationDate": 1547763720.822, "EstimatedNumberOfUsers": 1, "Id": "us-west-2_aaaaaaaaa", "LambdaConfig": {} } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「DescribeUserPool
」を参照してください。
-
次の例は、forget-device
を使用する方法を説明しています。
- AWS CLI
-
デバイスの「記憶済み」状態を解除するには
この例では、デバイスの「記憶済み」状態を解除します。
コマンド:
aws cognito-idp forget-device --device-key
us-west-2_abcd_1234-5678
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ForgetDevice
」を参照してください。
-
次のコード例は、forgot-password
を使用する方法を示しています。
- AWS CLI
-
強制的にパスワードを変更するには
次の
forgot-password
の例では、パスワードを変更するようにメッセージを jane@example.com に送信しています。aws cognito-idp forgot-password --client-id
38fjsnc484p94kpqsnet7mpld0
--usernamejane@example.com
出力:
{ "CodeDeliveryDetails": { "Destination": "j***@e***.com", "DeliveryMedium": "EMAIL", "AttributeName": "email" } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ForgotPassword
」を参照してください。
-
次のコード例は、get-csv-header
を使用する方法を示しています。
- AWS CLI
-
csv ヘッダーを作成するには
この例では、csv ヘッダーを作成しています。
ユーザーをインポートする方法の詳細については、「Importing Users into User Pools From a CSV File」を参照してください。
コマンド:
aws cognito-idp get-csv-header --user-pool-id
us-west-2_aaaaaaaaa
出力:
{ "UserPoolId": "us-west-2_aaaaaaaaa", "CSVHeader": [ "name", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "profile", "picture", "website", "email", "email_verified", "gender", "birthdate", "zoneinfo", "locale", "phone_number", "phone_number_verified", "address", "updated_at", "cognito:mfa_enabled", "cognito:username" ] }
... Importing Users into User Pools From a CSV File: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-using-import-tool.html
-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetCsvHeader
」を参照してください。
-
次の例は、get-group
を使用する方法を説明しています。
- AWS CLI
-
グループに関する情報を取得するには
この例では、MyGroup という名前のグループに関する情報を取得しています。
コマンド:
aws cognito-idp get-group --user-pool-id
us-west-2_aaaaaaaaa
--group-nameMyGroup
出力:
{ "Group": { "GroupName": "MyGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "A sample group.", "LastModifiedDate": 1548270073.795, "CreationDate": 1548270073.795 } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetGroup
」を参照してください。
-
次のコード例は、get-signing-certificate
を使用する方法を示しています。
- AWS CLI
-
署名用証明書を取得するには
この例では、ユーザープールの署名用証明書を取得しています。
コマンド:
aws cognito-idp get-signing-certificate --user-pool-id
us-west-2_aaaaaaaaa
出力:
{ "Certificate": "CERTIFICATE_DATA" }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetSigningCertificate
」を参照してください。
-
次の例は、get-ui-customization
を使用する方法を説明しています。
- AWS CLI
-
UI カスタマイズ情報を取得するには
この例では、ユーザープールの UI カスタマイズ情報を取得しています。
コマンド:
aws cognito-idp get-ui-customization --user-pool-id
us-west-2_aaaaaaaaa
出力:
{ "UICustomization": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientId": "ALL", "ImageUrl": "https://aaaaaaaaaaaaa.cloudfront.net/us-west-2_aaaaaaaaa/ALL/20190128231240/assets/images/image.jpg", "CSS": ".logo-customizable {\n\tmax-width: 60%;\n\tmax-height: 30%;\n}\n.banner-customizable {\n\tpadding: 25px 0px 25px 10px;\n\tbackground-color: lightgray;\n}\n.label-customizable {\n\tfont-weight: 300;\n}\n.textDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.idpDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.legalText-customizable {\n\tcolor: #747474;\n\tfont-size: 11px;\n}\n.submitButton-customizable {\n\tfont-size: 14px;\n\tfont-weight: bold;\n\tmargin: 20px 0px 10px 0px;\n\theight: 40px;\n\twidth: 100%;\n\tcolor: #fff;\n\tbackground-color: #337ab7;\n}\n.submitButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #286090;\n}\n.errorMessage-customizable {\n\tpadding: 5px;\n\tfont-size: 14px;\n\twidth: 100%;\n\tbackground: #F5F5F5;\n\tborder: 2px solid #D64958;\n\tcolor: #D64958;\n}\n.inputField-customizable {\n\twidth: 100%;\n\theight: 34px;\n\tcolor: #555;\n\tbackground-color: #fff;\n\tborder: 1px solid #ccc;\n}\n.inputField-customizable:focus {\n\tborder-color: #66afe9;\n\toutline: 0;\n}\n.idpButton-customizable {\n\theight: 40px;\n\twidth: 100%;\n\ttext-align: center;\n\tmargin-bottom: 15px;\n\tcolor: #fff;\n\tbackground-color: #5bc0de;\n\tborder-color: #46b8da;\n}\n.idpButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #31b0d5;\n}\n.socialButton-customizable {\n\theight: 40px;\n\ttext-align: left;\n\twidth: 100%;\n\tmargin-bottom: 15px;\n}\n.redirect-customizable {\n\ttext-align: center;\n}\n.passwordCheck-notValid-customizable {\n\tcolor: #DF3312;\n}\n.passwordCheck-valid-customizable {\n\tcolor: #19BF00;\n}\n.background-customizable {\n\tbackground-color: #faf;\n}\n", "CSSVersion": "20190128231240" } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetUiCustomization
」を参照してください。
-
次のコード例は、list-user-import-jobs
を使用する方法を示しています。
- AWS CLI
-
ユーザーインポートジョブを一覧表示するには
この例では、ユーザーインポートジョブを一覧表示しています。
ユーザーをインポートする方法の詳細については、「Importing Users into User Pools From a CSV File」を参照してください。
コマンド:
aws cognito-idp list-user-import-jobs --user-pool-id
us-west-2_aaaaaaaaa
--max-results20
出力:
{ "UserImportJobs": [ { "JobName": "Test2", "JobId": "import-d0OnwGA3mV", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548272793.069, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 }, { "JobName": "Test1", "JobId": "import-qQ0DCt2fRh", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548271795.471, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 }, { "JobName": "import-Test1", "JobId": "import-TZqNQvDRnW", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548271708.512, "StartDate": 1548277247.962, "CompletionDate": 1548277248.912, "Status": "Failed", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 1, "CompletionMessage": "Too many users have failed or been skipped during the import." } ] }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ListUserImportJobs
」を参照してください。
-
次のコード例は、list-user-pools
を使用する方法を示しています。
- AWS CLI
-
ユーザープールを一覧表示するには
次の例では、最大 20 のユーザープールを一覧表示します。
コマンド:
aws cognito-idp list-user-pools --max-results
20
出力:
{ "UserPools": [ { "CreationDate": 1547763720.822, "LastModifiedDate": 1547763720.822, "LambdaConfig": {}, "Id": "us-west-2_aaaaaaaaa", "Name": "MyUserPool" } ] }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ListUserPools
」を参照してください。
-
次の例は、list-users-in-group
を使用する方法を説明しています。
- AWS CLI
-
グループ内のユーザーを一覧表示するには
この例では、MyGroup グループのユーザーを一覧表示しています。
コマンド:
aws cognito-idp list-users-in-group --user-pool-id
us-west-2_aaaaaaaaa
--group-nameMyGroup
出力:
{ "Users": [ { "Username": "acf10624-80bb-401a-ac61-607bee2110ec", "Attributes": [ { "Name": "sub", "Value": "acf10624-80bb-401a-ac61-607bee2110ec" }, { "Name": "custom:CustomAttr1", "Value": "New Value!" }, { "Name": "email", "Value": "jane@example.com" } ], "UserCreateDate": 1548102770.284, "UserLastModifiedDate": 1548103204.893, "Enabled": true, "UserStatus": "CONFIRMED" }, { "Username": "22704aa3-fc10-479a-97eb-2af5806bd327", "Attributes": [ { "Name": "sub", "Value": "22704aa3-fc10-479a-97eb-2af5806bd327" }, { "Name": "email_verified", "Value": "true" }, { "Name": "email", "Value": "diego@example.com" } ], "UserCreateDate": 1548089817.683, "UserLastModifiedDate": 1548089817.683, "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD" } ] }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ListUsersInGroup
」を参照してください。
-
次のコード例は、list-users
を使用する方法を示しています。
- AWS CLI
-
ユーザーを一覧表示するには
この例では最大 20 のユーザーを一覧表示します。
コマンド:
aws cognito-idp list-users --user-pool-id
us-west-2_aaaaaaaaa
--limit20
出力:
{ "Users": [ { "Username": "22704aa3-fc10-479a-97eb-2af5806bd327", "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD", "UserCreateDate": 1548089817.683, "UserLastModifiedDate": 1548089817.683, "Attributes": [ { "Name": "sub", "Value": "22704aa3-fc10-479a-97eb-2af5806bd327" }, { "Name": "email_verified", "Value": "true" }, { "Name": "email", "Value": "mary@example.com" } ] } ] }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ListUsers
」を参照してください。
-
次のコード例は、resend-confirmation-code
を使用する方法を示しています。
- AWS CLI
-
確認コードを再送信するには
次の
resend-confirmation-code
例では、ユーザーjane
に確認コードを送信します。aws cognito-idp resend-confirmation-code \ --client-id
12a3b456c7de890f11g123hijk
\ --usernamejane
出力:
{ "CodeDeliveryDetails": { "Destination": "j***@e***.com", "DeliveryMedium": "EMAIL", "AttributeName": "email" } }
詳細については、「Amazon Cognito デベロッパーガイド」の「ユーザーアカウントのサインアップと確認」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「ResendConfirmationCode
」を参照してください。
-
次のコード例は、respond-to-auth-challenge
を使用する方法を示しています。
- AWS CLI
-
認可チャレンジに応答するには
この例では initiate-auth で開始された認可チャレンジに応答します。NEW_PASSWORD_REQUIRED チャレンジへの応答です。ユーザー jane@example.com のパスワードを設定します。
コマンド:
aws cognito-idp respond-to-auth-challenge --client-id
3n4b5urk1ft4fl3mg5e62d9ado
--challenge-nameNEW_PASSWORD_REQUIRED
--challenge-responses USERNAME=jane@example.com,NEW_PASSWORD="password" --session"SESSION_TOKEN"
出力:
{ "ChallengeParameters": {}, "AuthenticationResult": { "AccessToken": "ACCESS_TOKEN", "ExpiresIn": 3600, "TokenType": "Bearer", "RefreshToken": "REFRESH_TOKEN", "IdToken": "ID_TOKEN", "NewDeviceMetadata": { "DeviceKey": "us-west-2_fec070d2-fa88-424a-8ec8-b26d7198eb23", "DeviceGroupKey": "-wt2ha1Zd" } } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「RespondToAuthChallenge
」を参照してください。
-
次のコード例は、set-risk-configuration
を使用する方法を示しています。
- AWS CLI
-
リスク設定を行うには
この例では、ユーザープールのリスク設定を行っています。サインアップイベントアクションを NO_ACTION に設定します。
コマンド:
aws cognito-idp set-risk-configuration --user-pool-id
us-west-2_aaaaaaaaa
--compromised-credentials-risk-configurationEventFilter=SIGN_UP,Actions={EventAction=NO_ACTION}
出力:
{ "RiskConfiguration": { "UserPoolId": "us-west-2_aaaaaaaaa", "CompromisedCredentialsRiskConfiguration": { "EventFilter": [ "SIGN_UP" ], "Actions": { "EventAction": "NO_ACTION" } } } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「SetRiskConfiguration
」を参照してください。
-
次の例は、set-ui-customization
を使用する方法を説明しています。
- AWS CLI
-
UI のカスタマイズを設定するには
この例では、ユーザープールの CSS 設定をカスタマイズしています。
コマンド:
aws cognito-idp set-ui-customization --user-pool-id
us-west-2_aaaaaaaaa
--css".logo-customizable {\n\tmax-width: 60%;\n\tmax-height: 30%;\n}\n.banner-customizable {\n\tpadding: 25px 0px 25px 10px;\n\tbackground-color: lightgray;\n}\n.label-customizable {\n\tfont-weight: 300;\n}\n.textDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.idpDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.legalText-customizable {\n\tcolor: #747474;\n\tfont-size: 11px;\n}\n.submitButton-customizable {\n\tfont-size: 14px;\n\tfont-weight: bold;\n\tmargin: 20px 0px 10px 0px;\n\theight: 40px;\n\twidth: 100%;\n\tcolor: #fff;\n\tbackground-color: #337ab7;\n}\n.submitButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #286090;\n}\n.errorMessage-customizable {\n\tpadding: 5px;\n\tfont-size: 14px;\n\twidth: 100%;\n\tbackground: #F5F5F5;\n\tborder: 2px solid #D64958;\n\tcolor: #D64958;\n}\n.inputField-customizable {\n\twidth: 100%;\n\theight: 34px;\n\tcolor: #555;\n\tbackground-color: #fff;\n\tborder: 1px solid #ccc;\n}\n.inputField-customizable:focus {\n\tborder-color: #66afe9;\n\toutline: 0;\n}\n.idpButton-customizable {\n\theight: 40px;\n\twidth: 100%;\n\ttext-align: center;\n\tmargin-bottom: 15px;\n\tcolor: #fff;\n\tbackground-color: #5bc0de;\n\tborder-color: #46b8da;\n}\n.idpButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #31b0d5;\n}\n.socialButton-customizable {\n\theight: 40px;\n\ttext-align: left;\n\twidth: 100%;\n\tmargin-bottom: 15px;\n}\n.redirect-customizable {\n\ttext-align: center;\n}\n.passwordCheck-notValid-customizable {\n\tcolor: #DF3312;\n}\n.passwordCheck-valid-customizable {\n\tcolor: #19BF00;\n}\n.background-customizable {\n\tbackground-color: #faf;\n}\n"
出力:
{ "UICustomization": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientId": "ALL", "CSS": ".logo-customizable {\n\tmax-width: 60%;\n\tmax-height: 30%;\n}\n.banner-customizable {\n\tpadding: 25px 0px 25px 10px;\n\tbackground-color: lightgray;\n}\n.label-customizable {\n\tfont-weight: 300;\n}\n.textDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.idpDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.legalText-customizable {\n\tcolor: #747474;\n\tfont-size: 11px;\n}\n.submitButton-customizable {\n\tfont-size: 14px;\n\tfont-weight: bold;\n\tmargin: 20px 0px 10px 0px;\n\theight: 40px;\n\twidth: 100%;\n\tcolor: #fff;\n\tbackground-color: #337ab7;\n}\n.submitButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #286090;\n}\n.errorMessage-customizable {\n\tpadding: 5px;\n\tfont-size: 14px;\n\twidth: 100%;\n\tbackground: #F5F5F5;\n\tborder: 2px solid #D64958;\n\tcolor: #D64958;\n}\n.inputField-customizable {\n\twidth: 100%;\n\theight: 34px;\n\tcolor: #555;\n\tbackground-color: #fff;\n\tborder: 1px solid #ccc;\n}\n.inputField-customizable:focus {\n\tborder-color: #66afe9;\n\toutline: 0;\n}\n.idpButton-customizable {\n\theight: 40px;\n\twidth: 100%;\n\ttext-align: center;\n\tmargin-bottom: 15px;\n\tcolor: #fff;\n\tbackground-color: #5bc0de;\n\tborder-color: #46b8da;\n}\n.idpButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #31b0d5;\n}\n.socialButton-customizable {\n\theight: 40px;\n\ttext-align: left;\n\twidth: 100%;\n\tmargin-bottom: 15px;\n}\n.redirect-customizable {\n\ttext-align: center;\n}\n.passwordCheck-notValid-customizable {\n\tcolor: #DF3312;\n}\n.passwordCheck-valid-customizable {\n\tcolor: #19BF00;\n}\n.background-customizable {\n\tbackground-color: #faf;\n}\n", "CSSVersion": "20190129172214" } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「SetUiCustomization
」を参照してください。
-
次のコード例は、set-user-mfa-preference
を使用する方法を示しています。
- AWS CLI
-
ユーザー MFA を設定するには
次の
set-user-mfa-preference
の例では、MFA 配信オプションを変更しています。MFA 配信メディアを SMS に変更します。aws cognito-idp set-user-mfa-preference \ --access-token
"eyJra12345EXAMPLE"
\ --software-token-mfa-settingsEnabled=true,PreferredMfa=true
\ --sms-mfa-settingsEnabled=false,PreferredMfa=false
このコマンドでは何も出力されません。
詳細については、「Amazon Cognito デベロッパーガイド」の「Adding MFA to a user pool」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「SetUserMfaPreference
」を参照してください。
-
次の例は、set-user-settings
を使用する方法を説明しています。
- AWS CLI
-
ユーザー設定を行うには
この例では、MFA 配信設定を EMAIL に設定しています。
コマンド:
aws cognito-idp set-user-settings --access-token
ACCESS_TOKEN
--mfa-optionsDeliveryMedium=EMAIL
-
API の詳細については、「AWS CLI コマンドリファレンス」の「SetUserSettings
」を参照してください。
-
次のコード例は、sign-up
を使用する方法を示しています。
- AWS CLI
-
ユーザーをサインアップするには
この例では jane@example.com をサインアップします。
コマンド:
aws cognito-idp sign-up --client-id
3n4b5urk1ft4fl3mg5e62d9ado
--usernamejane@example.com
--passwordPASSWORD
--user-attributes Name="email",Value="jane@example.com" Name="name",Value="Jane"出力:
{ "UserConfirmed": false, "UserSub": "e04d60a6-45dc-441c-a40b-e25a787d4862" }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「SignUp
」を参照してください。
-
次のコード例は、start-user-import-job
を使用する方法を示しています。
- AWS CLI
-
ユーザーインポートジョブを開始するには
この例では、ユーザー入力ジョブを開始しています。
ユーザーをインポートする方法の詳細については、「Importing Users into User Pools From a CSV File」を参照してください。
コマンド:
aws cognito-idp start-user-import-job --user-pool-id
us-west-2_aaaaaaaaa
--job-idimport-TZqNQvDRnW
出力:
{ "UserImportJob": { "JobName": "import-Test10", "JobId": "import-lmpxSOuIzH", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548278378.928, "StartDate": 1548278397.334, "Status": "Pending", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「StartUserImportJob
」を参照してください。
-
次の例は、stop-user-import-job
を使用する方法を説明しています。
- AWS CLI
-
ユーザーインポートジョブを停止するには
この例では、ユーザー入力ジョブを停止しています。
ユーザーをインポートする方法の詳細については、「Importing Users into User Pools From a CSV File」を参照してください。
コマンド:
aws cognito-idp stop-user-import-job --user-pool-id
us-west-2_aaaaaaaaa
--job-idimport-TZqNQvDRnW
出力:
{ "UserImportJob": { "JobName": "import-Test5", "JobId": "import-Fx0kARISFL", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548278576.259, "StartDate": 1548278623.366, "CompletionDate": 1548278626.741, "Status": "Stopped", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0, "CompletionMessage": "The Import Job was stopped by the developer." } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「StopUserImportJob
」を参照してください。
-
次のコード例は、update-auth-event-feedback
を使用する方法を示しています。
- AWS CLI
-
認証イベントフィードバックを更新するには
この例では、認証イベントフィードバックを更新しています。イベント「Valid」をマークします。
コマンド:
aws cognito-idp update-auth-event-feedback --user-pool-id
us-west-2_aaaaaaaaa
--usernamediego@example.com
--event-idEVENT_ID
--feedback-tokenFEEDBACK_TOKEN
--feedback-value"Valid"
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateAuthEventFeedback
」を参照してください。
-
次のコード例は、update-device-status
を使用する方法を示しています。
- AWS CLI
-
デバイスステータスを更新するには
この例では、デバイスのステータスを「not_remembered」に更新しています。
コマンド:
aws cognito-idp update-device-status --access-token
ACCESS_TOKEN
--device-keyDEVICE_KEY
--device-remembered-status"not_remembered"
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateDeviceStatus
」を参照してください。
-
次のコード例は、update-group
を使用する方法を示しています。
- AWS CLI
-
グループを更新するには
この例では、MyGroup の説明と優先順位を更新しています。
コマンド:
aws cognito-idp update-group --user-pool-id
us-west-2_aaaaaaaaa
--group-nameMyGroup
--description"New description"
--precedence2
出力:
{ "Group": { "GroupName": "MyGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "New description", "RoleArn": "arn:aws:iam::111111111111:role/MyRole", "Precedence": 2, "LastModifiedDate": 1548800862.812, "CreationDate": 1548097827.125 } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateGroup
」を参照してください。
-
次の例は、update-resource-server
を使用する方法を説明しています。
- AWS CLI
-
リソースサーバーを更新するには
この例では、リソースサーバー Weather を更新しています。新しいスコープが追加されます。
コマンド:
aws cognito-idp update-resource-server --user-pool-id
us-west-2_aaaaaaaaa
--identifierweather.example.com
--nameWeather
--scopes ScopeName=NewScope,ScopeDescription="New scope description"出力:
{ "ResourceServer": { "UserPoolId": "us-west-2_aaaaaaaaa", "Identifier": "weather.example.com", "Name": "Happy", "Scopes": [ { "ScopeName": "NewScope", "ScopeDescription": "New scope description" } ] } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateResourceServer
」を参照してください。
-
次の例は、update-user-attributes
を使用する方法を説明しています。
- AWS CLI
-
ユーザー属性を更新するには
この例では、ユーザー属性「nickname」を更新しています。
コマンド:
aws cognito-idp update-user-attributes --access-token
ACCESS_TOKEN
--user-attributes Name="nickname",Value="Dan"-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateUserAttributes
」を参照してください。
-
次のコード例は、update-user-pool-client
を使用する方法を示しています。
- AWS CLI
-
ユーザープールのクライアントを更新するには
この例では、ユーザープールのクライアントの名前を更新しています。また、書き込み可能な属性「nickname」も追加されます。
コマンド:
aws cognito-idp update-user-pool-client --user-pool-id
us-west-2_aaaaaaaaa
--client-id3n4b5urk1ft4fl3mg5e62d9ado
--client-name"NewClientName"
--write-attributes"nickname"
出力:
{ "UserPoolClient": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientName": "NewClientName", "ClientId": "3n4b5urk1ft4fl3mg5e62d9ado", "LastModifiedDate": 1548802761.334, "CreationDate": 1548178931.258, "RefreshTokenValidity": 30, "WriteAttributes": [ "nickname" ], "AllowedOAuthFlowsUserPoolClient": false } }
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateUserPoolClient
」を参照してください。
-
次の例は、update-user-pool
を使用する方法を説明しています。
- AWS CLI
-
ユーザープールを更新するには
次の
update-user-pool
の例では、使用可能な各設定オプションの構文例を使用して、ユーザープールを変更しています。ユーザープールを更新するには、以前に設定されたすべてのオプションを指定する必要があります。指定しない場合は、デフォルト値にリセットされます。aws cognito-idp update-user-pool --user-pool-id
us-west-2_EXAMPLE
\ --policies PasswordPolicy=\{MinimumLength=6,RequireUppercase=true,RequireLowercase=true,RequireNumbers=true,RequireSymbols=true,TemporaryPasswordValidityDays=7\} \ --deletion-protectionACTIVE
\ --lambda-config PreSignUp="arn:aws:lambda:us-west-2:123456789012:function:cognito-test-presignup-function",PreTokenGeneration="arn:aws:lambda:us-west-2:123456789012:function:cognito-test-pretoken-function" \ --auto-verified-attributes"phone_number"
"email"
\ --verification-message-template \{\"SmsMessage\":\""Your code is {####}"
\",\"EmailMessage\":\""Your code is {####}"\",\"EmailSubject\":\""Your verification code"\",\"EmailMessageByLink\":\""Click {##here##} to verify your email address."\",\"EmailSubjectByLink\":\""Your verification link"\",\"DefaultEmailOption\":\"CONFIRM_WITH_LINK\"\} \ --sms-authentication-message "Your code is {####}" \ --user-attribute-update-settings AttributesRequireVerificationBeforeUpdate="email","phone_number" \ --mfa-configuration"OPTIONAL"
\ --device-configurationChallengeRequiredOnNewDevice=true,DeviceOnlyRememberedOnUserPrompt=true
\ --email-configuration SourceArn="arn:aws:ses:us-west-2:123456789012:identity/admin@example.com",ReplyToEmailAddress="amdin+noreply@example.com",EmailSendingAccount=DEVELOPER,From="admin@amazon.com",ConfigurationSet="test-configuration-set" \ --sms-configuration SnsCallerArn="arn:aws:iam::123456789012:role/service-role/SNS-SMS-Role",ExternalId="12345",SnsRegion="us-west-2" \ --admin-create-user-config AllowAdminCreateUserOnly=false,InviteMessageTemplate=\{SMSMessage=\""Welcome {username}. Your confirmation code is {####}"\",EmailMessage=\""Welcome {username}. Your confirmation code is {####}"\",EmailSubject=\""Welcome to MyMobileGame"\"\} \ --user-pool-tags "Function"="MyMobileGame","Developers"="Berlin" \ --admin-create-user-config AllowAdminCreateUserOnly=false,InviteMessageTemplate=\{SMSMessage=\""Welcome {username}. Your confirmation code is {####}"\",EmailMessage=\""Welcome {username}. Your confirmation code is {####}"\",EmailSubject=\""Welcome to MyMobileGame"\"\} \ --user-pool-add-ons AdvancedSecurityMode="AUDIT" \ --account-recovery-setting RecoveryMechanisms=\[\{Priority=1,Name="verified_email"\},\{Priority=2,Name="verified_phone_number"\}\]このコマンドでは何も出力されません。
詳細については、「Amazon Cognito デベロッパーガイド」の「ユーザープール設定の更定」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateUserPool
」を参照してください。
-