

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# ユーザープールのマルチリージョンレプリケーション
<a name="user-pool-multi-region"></a>

マルチリージョンレプリケーション (MRR) を使用すると、追加の にレプリカユーザープールを作成して AWS リージョン 、認証インフラストラクチャにビジネス継続性とディザスタリカバリ機能を提供できます。MRR を使用すると、登録されたユーザーは、リージョン内のリソースへの接続が失われてもアプリケーションに対して引き続き認証できるため、アプリケーションの可用性を維持できます。

MRR を設定すると、Amazon Cognito は共有ユーザープール ID を使用して個別のユーザープールを作成します。各レプリカユーザープールは、共有ユーザーディレクトリの認証サービスをホストします。プライマリユーザープールは、パスワードのリセットやユーザーサインアップなどの管理設定や書き込みオペレーションの信頼できるソースとして機能します。セカンダリユーザープールはユーザーを作成できません。プライマリユーザープールからほとんどの設定を継承し、フェイルオーバー状態では、ユーザーのサインインやトークン生成などの認証操作を処理できます。

**重要**  
現時点では、マルチリージョンレプリケーションはすべてのユーザープールで利用できるわけではありません。マルチリージョンレプリケーションには、機能とスケーラビリティが強化された最新の Amazon Cognito インフラストラクチャが必要です。一部のユーザープールはまだ以前のインフラストラクチャにあり、 によって AWS 新しいインフラストラクチャにアップグレードされるため、この機能はロック解除されます。Amazon Cognito コンソールでは、対象となるユーザープールにマルチリージョンレプリケーション設定オプションが表示され、対象外のプールには例外メッセージが表示されます。詳細については、 AWS 「 セキュリティブログ[」のAmazon Cognito が次世代インフラストラクチャで高度な機能をロック解除](https://aws.amazon.com/blogs/security/amazon-cognito-unlocks-advanced-capabilities-with-next-generation-infrastructure/)する」を参照してください。

## マルチリージョンレプリケーションについて知っておくべきこと
<a name="user-pool-multi-region-things-to-know"></a>
+ マルチリージョンレプリケーションには個別のアドオンコストがあり、ユーザープールが Essentials または Plus [機能プラン](cognito-sign-in-feature-plans.md)に含まれている必要があります。Lite 機能プランでは、ユーザープールで MRR を有効にすることはできません。
+ レプリケーションを有効にする AWS KMS 前に、 の[マルチリージョンカスタマーマネージドキー](https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html)を使用してユーザープールを設定する必要があります。キーは、ユーザープールレプリカ AWS リージョン を持つすべての で使用可能である必要があります。詳細については、「[データ暗号化](data-protection.md#data-encryption)」を参照してください。
+ リージョン間で一貫したトークン検証を行うには、更新された発行者を使用してユーザープールを設定することをお勧めします。詳細については、「[OIDC 発行者としての Amazon Cognito ユーザープール](federation-endpoints.md#user-pool-oidc-issuer)」を参照してください。
+ 新しいセカンダリユーザープールは `INACTIVE`状態で開始されます。本番稼働用のユーザープールをアクティブ化する前に、リージョン設定を確認して設定します。
+ リージョン設定はレプリカによって異なる場合があります。レプリカでは、以下の設定を個別に設定できます。他のすべての設定はプライマリユーザープールに設定され、セカンダリに自動的に同期されます。
  + E メール設定
  + 脅威保護通知の E メール設定
  + SMS 設定
  + Lambda トリガー
  + タグ
  + ログエクスポート設定
  + AWS WAF ウェブ ACLs
+ リージョン間のデータレプリケーションでは、短時間の遅延が発生する場合があります。プライマリユーザープールは設定とユーザーディレクトリの更新をセカンダリに同期し、このプロセスは結果整合性があります。

## マルチリージョンレプリケーションの制限
<a name="user-pool-multi-region-limitations"></a>
+ サインアップまたは管理者作成によって、セカンダリユーザープールで新しいユーザーを生成することはできません。フェデレーティッドユーザーは、以前にプライマリユーザープールにサインインしたことがある場合にのみ、フェイルオーバー状態のセカンダリユーザープールにサインインできます。
+ ユーザーは、セカンダリユーザープールでパスワードをリセットしたり、プロファイルを変更したりすることはできません。フェイルオーバー状態では、これらのオペレーションをユーザーインターフェイスで無効にし、ヘルスチェックがプライマリユーザープールへのアクセスを復元した後に使用できるようにします。
+ ユーザーディレクトリごとに、追加のリージョンに最大 1 つのセカンダリレプリカを持つことができます。対象となるユーザープールには、セカンダリレプリカを含めることができます。
+ TOTP MFA はセカンダリレプリカではサポートされていません。TOTP MFA が設定されたユーザーは、プライマリリージョンのユーザープールがリクエストを処理するときに認証する必要があります。
+ ロックアウトがリージョン間で同期されないまでのパスワードベースの認証試行の数。各レプリカは、失敗した認証試行の独自の数を維持します。

## マルチリージョンレプリケーションの設定
<a name="user-pool-multi-region-configure"></a>

マルチリージョンレプリケーションを有効にする前に、ユーザープールが、Essentials または Plus 機能プランとマルチリージョンカスタマーマネージド KMS キーの前提条件を満たしていることを確認してください。

------
#### [ AWS マネジメントコンソール ]

**ユーザープールのマルチリージョンレプリケーションを設定するには**

1. [Amazon Cognito コンソール](https://console.aws.amazon.com/cognito/home)にサインインします。

1. **[User pools]** (ユーザープール) を選択します。

1. リストから既存のユーザープールを選択するか、[新しいユーザープールを作成します](getting-started-user-pools.md)。

1. **[設定]** タブを選択します。

1. 左側のナビゲーションメニューで、**マルチリージョンレプリケーション**を選択します。

1. **レプリカユーザープールの作成** を選択します。

1. **リージョン**で、レプリカユーザープール AWS リージョン を作成する を選択します。

1. 設定の概要を確認し、**レプリカの作成**を選択します。

1. レプリカを作成したら、比較テーブルのリージョン設定を確認します。レプリカリージョンの必要に応じて、E メール設定、SMS 設定、Lambda トリガーなどのリージョン固有の設定を構成します。

1. ドメインの Route 53 ヘルスチェックを設定するには、**ドメインサービス**メニューに移動し、カスタムドメインを編集または追加し、**Route 53 ヘルスチェック ID** を設定します。

1. 本番トラフィックにレプリカを使用する準備ができたら、レプリカのステータスを**非アクティブ**から**アクティブ**に変更します。

------
#### [ API ]

レプリカユーザープールを作成するには、[CreateUserPoolReplica](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolReplica.html) オペレーションを使用します。次の例では、 のプライマリユーザープールの `us-west-2`リージョンにレプリカを作成します`us-east-1`。

```
{
 "UserPoolId": "{{us-east-1_EXAMPLE}}",
 "RegionName": "{{us-west-2}}",
 "UserPoolTags": {
    "Environment": "{{Production}}",
    "Application": "{{MyApp}}"
 }
}
```

レスポンスには、レプリカ情報が含まれます。

```
{
 "Replica": {
    "RegionName": "{{us-west-2}}",
    "UserPoolArn": "arn:aws:cognito-idp:{{us-west-2}}:{{111122223333}}:userpool/{{us-east-1_EXAMPLE}}",
    "Status": "PENDING_CREATE",
    "Role": "SECONDARY"
 }
}
```

また、フェイルオーバー用にドメインを設定する必要があります。Route 53 でヘルスチェックを設定し、[UpdateUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPoolDomain.html) リクエストでドメインに適用します。

```
{
 "CustomDomainConfig": { 
    "CertificateArn": "arn:aws:acm:us-east-1:{{111122223333}}:certificate/{{a1b2c3d4-5678-90ab-cdef-EXAMPLE11111}}"
 },
 "Domain": "{{auth.example.com}}",
 "ManagedLoginVersion": {{2}},
 "Routing": {
    "Failover": {
       "SecondaryRegion": "{{us-west-2}}",
       "PrimaryRoute53HealthCheckId": "{{a1b2c3d4-5678-90ab-cdef-EXAMPLE11111}}"
    }
 },
 "UserPoolId": "{{us-east-1_EXAMPLE}}"
}
```

本番稼働用にレプリカをアクティブ化するには、[UpdateUserPoolReplica](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPoolReplica.html) オペレーションを使用します。

```
{
 "UserPoolId": "{{us-east-1_EXAMPLE}}",
 "RegionName": "{{us-west-2}}",
 "Status": "ACTIVE"
}
```

レスポンスは、更新されたレプリカのステータスを確認します。

```
{
 "Replica": {
    "RegionName": "{{us-west-2}}",
    "UserPoolArn": "arn:aws:cognito-idp:{{us-west-2}}:{{111122223333}}:userpool/{{us-east-1_EXAMPLE}}",
    "Status": "ACTIVE",
    "Role": "SECONDARY"
 }
}
```

------

## セカンダリリージョンでサポートされている API オペレーション
<a name="user-pool-multi-region-api-operations"></a>

Amazon Cognito は、セカンダリリージョンの API オペレーションのサブセットをサポートしています。使用可能なオペレーションは、レプリカのステータスによって異なります。`INACTIVE` ステータスのレプリカは、読み取りおよび設定オペレーションの限られたセットをサポートします。`ACTIVE` ステータスのレプリカは、追加の認証およびセッション管理オペレーションをサポートします。ここにリストされていないオペレーションは、プライマリリージョンでのみ使用できます。

### INACTIVE セカンダリリージョンのオペレーション
<a name="user-pool-multi-region-api-operations-inactive"></a>

`INACTIVE` ステータスが のセカンダリリージョンのレプリカユーザープールでは、次の Amazon Cognito API オペレーションが許可されます。
+ [AdminGetDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminGetDevice.html)
+ [AdminGetUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminGetUser.html)
+ [AdminListDevices](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminListDevices.html)
+ [AdminListGroupsForUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminListGroupsForUser.html)
+ [AdminListUserAuthEvents](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminListUserAuthEvents.html)
+ [AssociateWebACL](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AssociateWebACL.html)
+ [CreateUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolDomain.html)
+ [DeleteUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteUserPoolDomain.html)
+ [DeleteUserPoolReplica](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DeleteUserPoolReplica.html)
+ [DescribeIdentityProvider](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeIdentityProvider.html)
+ [DescribeManagedLoginBranding](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeManagedLoginBranding.html)
+ [DescribeManagedLoginBrandingByClient](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeManagedLoginBrandingByClient.html)
+ [DescribeResourceServer](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeResourceServer.html)
+ [DescribeRiskConfiguration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeRiskConfiguration.html)
+ [DescribeTerms](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeTerms.html)
+ [DescribeUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPool.html)
+ [DescribeUserPoolClient](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPoolClient.html)
+ [DescribeUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DescribeUserPoolDomain.html)
+ [DisassociateWebACL](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_DisassociateWebACL.html)
+ [GetGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetGroup.html)
+ [GetLogDeliveryConfiguration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetLogDeliveryConfiguration.html)
+ [GetSigningCertificate](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetSigningCertificate.html)
+ [GetUICustomization](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUICustomization.html)
+ [GetUserPoolMfaConfig](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUserPoolMfaConfig.html)
+ [ListIdentityProviders](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListIdentityProviders.html)
+ [ListGroups](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListGroups.html)
+ [ListResourceServers](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListResourceServers.html)
+ [ListTagsForResource](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListTagsForResource.html)
+ [ListTerms](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListTerms.html)
+ [ListUserPoolClients](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUserPoolClients.html)
+ [ListUserPoolClientSecrets](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUserPoolClientSecrets.html)
+ [ListUserPoolReplicas](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUserPoolReplicas.html)
+ [ListUserPools](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUserPools.html)
+ [ListUsers](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html)
+ [ListUsersInGroup](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsersInGroup.html)
+ [SetLogDeliveryConfiguration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetLogDeliveryConfiguration.html)
+ [SetRiskConfiguration](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetRiskConfiguration.html)
+ [SetUserPoolMfaConfig](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SetUserPoolMfaConfig.html)
+ [TagResource](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_TagResource.html)
+ [UntagResource](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UntagResource.html)
+ [UpdateUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPool.html)
+ [UpdateUserPoolDomain](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPoolDomain.html)
+ [UpdateUserPoolReplica](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPoolReplica.html)

### ACTIVE セカンダリリージョンの追加オペレーション
<a name="user-pool-multi-region-api-operations-active"></a>

`ACTIVE` ステータスのセカンダリリージョンのレプリカユーザープールは、前述のすべてのオペレーションに加えて、次の認証およびセッション管理オペレーションを許可します。
+ [AdminInitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html)
+ [AdminRespondToAuthChallenge](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminRespondToAuthChallenge.html)
+ [AdminUpdateAuthEventFeedback](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUpdateAuthEventFeedback.html)
+ [AdminUserGlobalSignOut](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminUserGlobalSignOut.html)
+ [GetDevice](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetDevice.html)
+ [GetIdentityProviderByIdentifier](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetIdentityProviderByIdentifier.html)
+ [GetTokensFromRefreshToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetTokensFromRefreshToken.html)
+ [GetUser](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUser.html)
+ [GetUserAuthFactors](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUserAuthFactors.html)
+ [GlobalSignOut](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GlobalSignOut.html)
+ [InitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html)
+ [ListDevices](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html)
+ [ListWebAuthnCredentials](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListWebAuthnCredentials.html)
+ [RespondToAuthChallenge](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_RespondToAuthChallenge.html)
+ [RevokeToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_RevokeToken.html)
+ [UpdateAuthEventFeedback](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateAuthEventFeedback.html)

## マルチリージョンユーザープールでのフェイルオーバー
<a name="user-pool-multi-region-failover"></a>

マルチリージョンユーザープールを使用すると、マネージドログイン、フェデレーティッドログイン、および 2 つの間の直接 API コールをフェイルオーバーできます AWS リージョン。マネージドログインフェデレーションフェイルオーバーは、カスタムドメインまたはユーザープールで設定されたプレフィックス (Cognito) ドメインで使用できます。レプリカユーザープールで別のカスタムドメインを設定することはできません。

### マネージドログイン、フェデレーション、machine-to-machine認可のフェイルオーバー
<a name="user-pool-multi-region-failover-managed-login"></a>

フェイルオーバーは、プライマリユーザープールに[カスタムドメイン](cognito-user-pools-add-custom-domain.md)または[プレフィックスドメイン](cognito-user-pools-assign-domain-prefix.md)がある場合に使用できます。ユーザープールドメインは、[認可](authorization-endpoint.md)エンドポイントや[トークン](token-endpoint.md)エンドポイントなどの OAuth 2.0 リソースを提供し、OIDC、SAML、ソーシャルプロバイダーなどのサードパーティーフェデレーションプロバイダーからの IdP レスポンスを処理します。

フェイルオーバーを有効にするには、Route 53 で[ヘルスチェック](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover.html)を設定し、ドメインの `Routing`フィールドを設定します。正常または異常な状態をトリガーする要因を決定します。ヘルスチェックが異常な状態にある場合、Amazon Cognito はセカンダリレプリカユーザープールからマネージドログインページと認証オペレーションを提供します。ヘルスチェックが正常な状態になると、Amazon Cognito はトラフィックをプライマリレプリカにルーティングし始めます。

カスタムドメインの DNS レコードは、Route 53 または任意のサードパーティー DNS プロバイダーを使用できます。CloudFront ディストリビューションであるターゲットエイリアスを指す有効な CNAME レコードが DNS プロバイダーにあることを確認します。エイリアスターゲットは、Amazon Cognito コンソールの**ドメイン**ページで確認できます。

**コンソールでヘルスチェック ID を更新するには**

1. [Amazon Cognito コンソール](https://console.aws.amazon.com/cognito/home)にサインインします。

1. **ユーザープール**を選択し、ユーザープールを選択します。

1. メニューから**「ブランド**」で**「ドメイン**」を選択します。

1. **カスタムドメイン**セクションで、編集オプションを選択し、**マルチリージョンフェイルオーバーの編集**を選択します。

1. **マルチリージョンフェイルオーバーを有効にする**オプションを切り替えます。

1. 使用可能なヘルスチェックから Route 53 ヘルスチェック ID を選択します。

1. **[Save changes]** (変更の保存) をクリックします。

### Amazon Cognito APIsと SDKsフェイルオーバー
<a name="user-pool-multi-region-failover-api"></a>

Amazon Cognito APIs または SDKs を使用する場合、カスタムドメインは使用されず、アプリケーションは Amazon Cognito サービスリージョンエンドポイントにトラフィックをルーティングして、認証やその他の API コールを処理します。

単一ページアプリケーション (SPA) やモバイルアプリなどのパブリッククライアントを使用するアプリケーションフロントエンドのみがある場合、それに応じて API コールをルーティングするには、アプリケーションが動的である必要があります。Amazon Cognito によるリージョン認証を開始するには、サーバーレスアプリケーションのバックエンドを検討してください。

バックエンドを持つアプリケーションがある場合、認証するユーザープールを決定するロジックをここで決定できます。

マネージドログインエンドポイントと APIs の両方を使用する場合は、同じ Route 53 ヘルスチェックを使用して、アプリケーションが Amazon Cognito API コールを指示するリージョンを決定します。