

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

# OpenSearch ドメインへのクロスリージョンデータアクセス
<a name="application-cross-region-data-access-domains"></a>

OpenSearch UI アプリケーションは、異なる の OpenSearch ドメインにアクセスする AWS リージョン ように 1 つの AWS リージョンで設定できます。これにより、同じパーティション内の複数の AWS リージョンにわたって OpenSearch ドメインからデータを集約する統合ダッシュボードを作成できます。クロスリージョンデータソースのサポートでは、ターゲットドメインできめ細かなアクセスコントロールを有効にする必要があります。きめ細かなアクセスコントロールは、ドメインアクセスポリシー以外にも追加の認可レイヤーを提供するため、個々のインデックス、ドキュメント、フィールドへのアクセスを制御できます。

## 主要なコンセプト
<a name="cross-region-key-concepts"></a>

アプリケーションリージョン  
OpenSearch UI アプリケーションがホスト AWS リージョン されている 。

ターゲット リージョン  
 AWS リージョン OpenSearch ドメインが存在する 。これは、OpenSearch UI がそのリージョンで使用可能かどうかに関係なく、同じパーティション内の任意のリージョンにすることができます。

クロスアカウントロール  
データソースの関連付け中のみ使用されるターゲットアカウントの IAM ロール。OpenSearch UI はこのロールを引き受けて を呼び出します。これにより`es:DescribeDomain`、ドメインエンドポイントを取得し、きめ細かなアクセスコントロールが有効になっていることを確認します。このロールは、ドメインがアプリケーションとは異なるアカウントにある場合にのみ必要です。詳細については、「[OpenSearch ドメインへのクロスアカウントデータアクセス](application-cross-account-data-access-domains.md)」を参照してください。

IAM Identity Center アプリケーションロール  
IAM Identity Center ユーザーデータプレーンアクセスに使用されるアプリケーションアカウントの IAM ロール。

サポートされているリージョン (VPC ドメインの場合)  
VPC ドメインの場合、VPC AWS リージョンエンドポイントを承認するときに OpenSearch UI アプリケーションがホストされている を許可リストに登録する必要があります。この許可リストは、OpenSearch UI が VPC ドメインを呼び出すために必要です。

## 前提条件
<a name="cross-region-prerequisites"></a>

クロスリージョンデータアクセスを設定する前に、以下があることを確認してください。
+ AWS CLI のインストールと設定
+ アプリケーションリージョンとターゲットリージョンの両方 AWS アカウント の へのアクセス
+ きめ細かなアクセスコントロールが有効になっている OpenSearch ドメイン。マルチリージョンデータソースの関連付けは、きめ細かなアクセスコントロールが有効になっているドメインでのみサポートされます。
+ クロスアカウントシナリオの場合: ソースとターゲットの両方へのアクセス AWS アカウント
+ IAM Identity Center フローの場合: AWS IAM アイデンティティセンター 組織インスタンス。OpenSearch UI アプリケーションは、IAM Identity Center インスタンスと同じリージョンに存在する必要があります。

## シナリオ
<a name="cross-region-scenarios"></a>

認証方法とドメイン設定に一致するシナリオを選択します。
+ [シナリオ 1: 別のリージョンのパブリックドメインにアクセスする IAM ユーザー](#cross-region-scenario-1)
+ [シナリオ 2: 別のリージョンのパブリックドメインにアクセスする IAM Identity Center ユーザー](#cross-region-scenario-2)
+ [シナリオ 3: 別のリージョンの VPC ドメインにアクセスする IAM ユーザー](#cross-region-scenario-3)
+ [シナリオ 4: 別のリージョンの VPC ドメインにアクセスする IAM Identity Center ユーザー](#cross-region-scenario-4)

各シナリオは、同じアカウントのクロスリージョンアクセスを対象としています。クロスアカウントクロスリージョンアクセスの場合は、これらのシナリオの手順と、「」で説明されているクロスアカウントロールの設定を組み合わせてください[OpenSearch ドメインへのクロスアカウントデータアクセス](application-cross-account-data-access-domains.md)。

## シナリオ 1: 別のリージョンのパブリックドメインにアクセスする IAM ユーザー
<a name="cross-region-scenario-1"></a>

このシナリオでは、1 つのリージョンに OpenSearch UI アプリケーションを作成し、同じアカウント内の別のリージョンにあるパブリック OpenSearch ドメインに接続します。

### ステップ 1: OpenSearch ドメインを作成する (ターゲットリージョン)
<a name="cross-region-scenario-1-step-1"></a>

きめ細かなアクセスコントロールを有効にして、ターゲットリージョンに OpenSearch ドメインを作成します。アクセスポリシーの範囲をアカウントのルートまたは特定の IAM プリンシパルに設定します。

```
aws opensearch create-domain \
  --domain-name {{domain-name}} \
  --engine-version OpenSearch_2.19 \
  --cluster-config InstanceType=m5.large.search,InstanceCount=1 \
  --ebs-options "EBSEnabled=true,VolumeType=gp3,VolumeSize=100" \
  --advanced-security-options '{"Enabled":true,"InternalUserDatabaseEnabled":true,"MasterUserOptions":{"MasterUserName":"{{admin}}","MasterUserPassword":"{{master-password}}"}}' \
  --node-to-node-encryption-options '{"Enabled":true}' \
  --encryption-at-rest-options '{"Enabled":true}' \
  --domain-endpoint-options '{"EnforceHTTPS":true,"TLSSecurityPolicy":"Policy-Min-TLS-1-2-2019-07"}' \
  --access-policies '{"Version":"2012-10-17",		 	 	 "Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::{{account-id}}:root"},"Action":"es:ESHttp*","Resource":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{domain-name}}/*"}]}' \
  --region {{target-region}}
```

続行する`Active`前に、ドメインのステータスが になるまで待ちます。

### ステップ 2: OpenSearch UI アプリケーションを作成する (アプリケーションリージョン)
<a name="cross-region-scenario-1-step-2"></a>

クロスリージョンデータソースを使用して、アプリケーションリージョンにアプリケーションを作成します。リージョンはデータソース ARN から自動的に抽出されます。

```
aws opensearch create-application \
  --region {{application-region}} \
  --name "{{cross-region-iam-app}}" \
  --data-sources '[{
    "dataSourceArn":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{domain-name}}",
    "dataSourceDescription":"{{Cross-region domain}}"
  }]' \
  --app-configs '[{"key":"opensearchDashboards.dashboardAdmin.users","value":"[\"{{test-user}}\"]"}]'
```

### ステップ 3: 検証とアクセス
<a name="cross-region-scenario-1-step-3"></a>

アプリケーションの詳細を取得してエンドポイント URL を取得します。

```
aws opensearch get-application \
  --region {{application-region}} \
  --id {{application-id}}
```
+ レスポンスからアプリケーションエンドポイント URL に移動します。
+ IAM 認証情報を使用してサインインします。
+ IAM ユーザーは、独自の認証情報を使用してデータプレーンリクエストに署名します。
+ ターゲットドメインのアクセスポリシーとバックエンドロールマッピングは、ユーザーがアクセスできるデータを制御します。

## シナリオ 2: 別のリージョンのパブリックドメインにアクセスする IAM Identity Center ユーザー
<a name="cross-region-scenario-2"></a>

このシナリオでは、1 つのリージョンで IAM アイデンティティセンター認証を使用して OpenSearch UI アプリケーションを作成し、同じアカウント内の別のリージョンのパブリック OpenSearch ドメインに接続します。

### ステップ 1: IAM アイデンティティセンターを有効にして OpenSearch ドメインを作成する (ターゲットリージョン)
<a name="cross-region-scenario-2-step-1"></a>

きめ細かなアクセスコントロールと IAM Identity Center 統合を有効にして、ターゲットリージョンに OpenSearch ドメインを作成します。で `--identity-center-options`パラメータを使用して`IdentityCenterInstanceRegion`、IAM Identity Center インスタンスが配置されているリージョンを指定します。このリージョンは、OpenSearch UI アプリケーションがホストされているリージョンと同じである必要があります。

```
aws opensearch create-domain \
  --domain-name {{domain-name}} \
  --engine-version OpenSearch_2.19 \
  --cluster-config InstanceType=m5.large.search,InstanceCount=1 \
  --ebs-options "EBSEnabled=true,VolumeType=gp3,VolumeSize=100" \
  --advanced-security-options '{"Enabled":true,"InternalUserDatabaseEnabled":true,"MasterUserOptions":{"MasterUserName":"{{admin}}","MasterUserPassword":"{{master-password}}"}}' \
  --node-to-node-encryption-options '{"Enabled":true}' \
  --encryption-at-rest-options '{"Enabled":true}' \
  --domain-endpoint-options '{"EnforceHTTPS":true,"TLSSecurityPolicy":"Policy-Min-TLS-1-2-2019-07"}' \
  --identity-center-options '{"EnabledAPIAccess":true,"IdentityCenterInstanceARN":"arn:aws:sso:::instance/ssoins-{{instance-id}}","IdentityCenterInstanceRegion":"{{idc-region}}","RolesKey":"GroupId","SubjectKey":"UserId"}' \
  --access-policies '{"Version":"2012-10-17",		 	 	 "Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::{{account-id}}:role/{{NeoIdCAppRole}}"},"Action":"es:ESHttp*","Resource":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{domain-name}}/*"}]}' \
  --region {{target-region}}
```

続行する`Active`前に、ドメインのステータスが になるまで待ちます。

### ステップ 2: IAM Identity Center アプリケーションの IAM ロールを作成する
<a name="cross-region-scenario-2-step-2"></a>

OpenSearch UI が IAM Identity Center ユーザーデータプレーンアクセスに使用する IAM ロールを作成します。

**IAM Identity Center アプリケーションロールを作成するには**

1. `sts:AssumeRole` ステートメントのみを使用して信頼ポリシーを作成します。次のステップでアプリケーションを作成した後、このポリシーを更新して `sts:SetContext`ステートメントを追加します。

   ```
   {
     "Version": "2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": {
           "Service": "application.opensearchservice.amazonaws.com"
         },
         "Action": "sts:AssumeRole"
       }
     ]
   }
   ```

1. アクセス許可ポリシーを作成します。

   ```
   {
     "Version": "2012-10-17",		 	 	 
     "Statement": [{
       "Sid": "OpenSearchDomain",
       "Effect": "Allow",
       "Action": ["es:ESHttp*"],
       "Resource": "arn:aws:es:{{target-region}}:{{account-id}}:domain/{{domain-name}}/*"
     }]
   }
   ```

1. ロールを作成し、ポリシーをアタッチします。

   ```
   aws iam create-role \
     --role-name {{NeoIdCAppRole}} \
     --assume-role-policy-document file://{{neoidc-trust-policy.json}}
   
   aws iam put-role-policy \
     --role-name {{NeoIdCAppRole}} \
     --policy-name {{NeoIdCAppPermissions}} \
     --policy-document file://{{neoidc-permissions-policy.json}}
   ```

### ステップ 3: IAM アイデンティティセンターで OpenSearch UI アプリケーションを作成する (アプリケーションリージョン)
<a name="cross-region-scenario-2-step-3"></a>

**注記**  
IAM Identity Center インスタンスが OpenSearch UI アプリケーションリージョンと同じリージョンにあることを確認します。

```
aws opensearch create-application \
  --region {{application-region}} \
  --name "{{cross-region-idc-app}}" \
  --iam-identity-center-options '{
    "enabled":true,
    "iamIdentityCenterInstanceArn":"arn:aws:sso:::instance/ssoins-{{instance-id}}",
    "iamRoleForIdentityCenterApplicationArn":"arn:aws:iam::{{account-id}}:role/{{NeoIdCAppRole}}"
  }' \
  --data-sources '[{
    "dataSourceArn":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{domain-name}}",
    "dataSourceDescription":"{{Cross-region domain}}"
  }]' \
  --app-configs '[{"key":"opensearchDashboards.dashboardAdmin.users","value":"[\"{{test-user}}\"]"}]'
```

アプリケーションを作成したら、レスポンスの SSO アプリケーション ID を書き留めます。次に、IAM Identity Center アプリケーションロールの信頼ポリシーを更新して、`sts:SetContext`ステートメントを追加します。

```
{
  "Version": "2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "application.opensearchservice.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    },
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "application.opensearchservice.amazonaws.com"
      },
      "Action": "sts:SetContext",
      "Condition": {
        "ForAllValues:ArnEquals": {
          "sts:RequestContextProviders": "arn:aws:iam::{{account-id}}:oidc-provider/portal.sso.{{idc-region}}.amazonaws.com/apl/{{application-id}}"
        }
      }
    }
  ]
}
```

```
aws iam update-assume-role-policy \
  --role-name {{NeoIdCAppRole}} \
  --policy-document file://{{updated-trust-policy.json}}
```

### ステップ 4: IAM Identity Center ユーザーとグループを作成して割り当てる
<a name="cross-region-scenario-2-step-4"></a>

**IAM Identity Center ユーザーを作成する**  
以下のコマンドを実行してください。{{プレースホルダー値}}を、ユーザー自身の情報に置き換えます。

```
aws identitystore create-user \
  --identity-store-id {{d-directory-id}} \
  --user-name {{user-email}} \
  --display-name "{{display-name}}" \
  --name Formatted=string,FamilyName={{last-name}},GivenName={{first-name}} \
  --emails Value={{user-email}},Type=work,Primary=true
```

**IAM Identity Center グループを作成し、ユーザーを追加する**  
以下の コマンドを実行します。

```
aws identitystore create-group \
  --identity-store-id {{d-directory-id}} \
  --display-name "{{OpenSearchUsers}}" \
  --description "{{Users with OpenSearch access}}"

aws identitystore create-group-membership \
  --identity-store-id {{d-directory-id}} \
  --group-id {{group-id}} \
  --member-id UserId={{user-id}}
```

**ユーザーまたはグループをアプリケーションに割り当てる**  
次のコマンドを実行します。

```
aws sso-admin create-application-assignment \
  --application-arn "arn:aws:sso::{{account-id}}:application/ssoins-{{instance-id}}/apl-{{application-id}}" \
  --principal-id {{user-id-or-group-id}} \
  --principal-type {{USER}}
```

**ターゲットドメインでバックエンドロールマッピングを設定する**  
IAM Identity Center グループをターゲットドメインの OpenSearch セキュリティロールにマッピングします。

```
curl -XPATCH "https://{{domain-endpoint}}/_plugins/_security/api/rolesmapping/all_access" \
  -u {{admin}}:{{master-password}} \
  -H 'Content-Type: application/json' \
  -d '[{"op": "add", "path": "/backend_roles", "value": ["{{group-id}}"]}]'
```

### ステップ 5: 検証とアクセス
<a name="cross-region-scenario-2-step-5"></a>

アプリケーションの詳細を取得してエンドポイント URL を取得します。

```
aws opensearch get-application \
  --region {{application-region}} \
  --id {{application-id}}
```
+ アプリケーションエンドポイント URL に移動します。
+ IAM Identity Center ユーザー認証情報を使用してサインインします。
+ IAM Identity Center ユーザーのデータリクエストは、IAM Identity Center アプリケーションロールで署名されます。
+ ドメインコントロールデータアクセス許可のバックエンドロールマッピング。

## シナリオ 3: 別のリージョンの VPC ドメインにアクセスする IAM ユーザー
<a name="cross-region-scenario-3"></a>

このシナリオでは、1 つのリージョンに OpenSearch UI アプリケーションを作成し、同じアカウント内の別のリージョンの VPC OpenSearch ドメインに接続します。VPC ドメインには、追加のネットワーク設定と、クロスリージョンサポートによる明示的な VPC エンドポイント認可が必要です。

### ステップ 1: VPC をセットアップする (ターゲットリージョン)
<a name="cross-region-scenario-3-step-1"></a>

ターゲットリージョンに VPC がすでに存在する場合は、このステップをスキップします。

```
# Create VPC
aws ec2 create-vpc \
  --cidr-block 10.0.0.0/16 \
  --region {{target-region}}

# Create subnet
aws ec2 create-subnet \
  --vpc-id {{vpc-id}} \
  --cidr-block 10.0.1.0/24 \
  --availability-zone {{target-region}}a \
  --region {{target-region}}

# Create security group
aws ec2 create-security-group \
  --group-name {{opensearch-vpc-sg}} \
  --description "Security group for OpenSearch VPC domain" \
  --vpc-id {{vpc-id}} \
  --region {{target-region}}

# Allow inbound HTTPS
aws ec2 authorize-security-group-ingress \
  --group-id {{security-group-id}} \
  --protocol tcp \
  --port 443 \
  --cidr 10.0.0.0/16 \
  --region {{target-region}}
```

[VPC ドメインの作成](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/vpc.html)について詳しく説明します。

### ステップ 2: VPC ドメインを作成する (ターゲットリージョン)
<a name="cross-region-scenario-3-step-2"></a>

```
aws opensearch create-domain \
  --domain-name {{vpc-domain-name}} \
  --engine-version OpenSearch_2.19 \
  --cluster-config InstanceType=m5.large.search,InstanceCount=1 \
  --ebs-options "EBSEnabled=true,VolumeType=gp3,VolumeSize=100" \
  --vpc-options "SubnetIds={{subnet-id}},SecurityGroupIds={{security-group-id}}" \
  --advanced-security-options '{"Enabled":true,"InternalUserDatabaseEnabled":true,"MasterUserOptions":{"MasterUserName":"{{admin}}","MasterUserPassword":"{{master-password}}"}}' \
  --node-to-node-encryption-options '{"Enabled":true}' \
  --encryption-at-rest-options '{"Enabled":true}' \
  --domain-endpoint-options '{"EnforceHTTPS":true,"TLSSecurityPolicy":"Policy-Min-TLS-1-2-2019-07"}' \
  --access-policies '{"Version":"2012-10-17",		 	 	 "Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::{{account-id}}:root"},"Action":"es:ESHttp*","Resource":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{vpc-domain-name}}/*"}]}' \
  --region {{target-region}}
```

続行する`Active`前に、ドメインのステータスが になるまで待ちます。

### ステップ 3: クロスリージョンサポート (ターゲットリージョン) を使用して OpenSearch UI サービスプリンシパルの VPC エンドポイントを承認する
<a name="cross-region-scenario-3-step-3"></a>

```
# Authorize the service principal with cross-region support
aws opensearch authorize-vpc-endpoint-access \
  --domain-name {{vpc-domain-name}} \
  --service "application.opensearchservice.amazonaws.com" \
  --service-options '{"SupportedRegions":["{{target-region}}","{{application-region}}"]}' \
  --region {{target-region}}

# Verify authorization
aws opensearch list-vpc-endpoint-access \
  --domain-name {{vpc-domain-name}} \
  --region {{target-region}}
```

予想されるレスポンス

```
{
  "AuthorizedPrincipalList": [
    {
      "PrincipalType": "AWS_SERVICE",
      "Principal": "application.opensearchservice.amazonaws.com",
      "ServiceOptions": {
        "SupportedRegions": ["{{target-region}}", "{{application-region}}"]
      }
    }
  ]
}
```

### ステップ 4: OpenSearch UI アプリケーションを作成する (アプリケーションリージョン)
<a name="cross-region-scenario-3-step-4"></a>

```
aws opensearch create-application \
  --region {{application-region}} \
  --name "{{cross-region-vpc-iam-app}}" \
  --data-sources '[{
    "dataSourceArn":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{vpc-domain-name}}",
    "dataSourceDescription":"{{Cross-region VPC domain}}"
  }]' \
  --app-configs '[{"key":"opensearchDashboards.dashboardAdmin.users","value":"[\"{{test-user}}\"]"}]'
```

### ステップ 5: 検証とアクセス
<a name="cross-region-scenario-3-step-5"></a>

アプリケーションの詳細を取得してエンドポイント URL を取得します。

```
aws opensearch get-application \
  --region {{application-region}} \
  --id {{application-id}}
```
+ レスポンスからアプリケーションエンドポイント URL に移動します。
+ IAM 認証情報を使用してサインインします。
+ IAM ユーザーは、独自の認証情報を使用してデータプレーンリクエストに署名します。
+ ターゲットドメインのアクセスポリシーとバックエンドロールマッピングは、ユーザーがアクセスできるデータを制御します。

## シナリオ 4: 別のリージョンの VPC ドメインにアクセスする IAM Identity Center ユーザー
<a name="cross-region-scenario-4"></a>

このシナリオでは、1 つのリージョンで IAM アイデンティティセンター認証を使用して OpenSearch UI アプリケーションを作成し、同じアカウント内の別のリージョンの VPC OpenSearch ドメインに接続します。

### ステップ 1: VPC をセットアップする (ターゲットリージョン)
<a name="cross-region-scenario-4-step-1"></a>

ターゲットリージョンに VPC がすでに存在する場合は、このステップをスキップします。

```
# Create VPC
aws ec2 create-vpc \
  --cidr-block 10.0.0.0/16 \
  --region {{target-region}}

# Create subnet
aws ec2 create-subnet \
  --vpc-id {{vpc-id}} \
  --cidr-block 10.0.1.0/24 \
  --availability-zone {{target-region}}a \
  --region {{target-region}}

# Create security group
aws ec2 create-security-group \
  --group-name {{opensearch-vpc-sg}} \
  --description "Security group for OpenSearch VPC domain" \
  --vpc-id {{vpc-id}} \
  --region {{target-region}}

# Allow inbound HTTPS
aws ec2 authorize-security-group-ingress \
  --group-id {{security-group-id}} \
  --protocol tcp \
  --port 443 \
  --cidr 10.0.0.0/16 \
  --region {{target-region}}
```

[VPC ドメインの作成](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/vpc.html)について詳しく説明します。

### ステップ 2: IAM アイデンティティセンターを有効にして VPC ドメインを作成する (ターゲットリージョン)
<a name="cross-region-scenario-4-step-2"></a>

きめ細かなアクセスコントロール、IAM Identity Center 統合、VPC 設定を有効にして、ターゲットリージョンに OpenSearch ドメインを作成します。アクセスポリシーを更新して IAM Identity Center アプリケーションロールを許可し、 `--identity-center-options`パラメータを追加します。

```
aws opensearch create-domain \
  --domain-name {{vpc-domain-name}} \
  --engine-version OpenSearch_2.19 \
  --cluster-config InstanceType=m5.large.search,InstanceCount=1 \
  --ebs-options "EBSEnabled=true,VolumeType=gp3,VolumeSize=100" \
  --vpc-options "SubnetIds={{subnet-id}},SecurityGroupIds={{security-group-id}}" \
  --advanced-security-options '{"Enabled":true,"InternalUserDatabaseEnabled":true,"MasterUserOptions":{"MasterUserName":"{{admin}}","MasterUserPassword":"{{master-password}}"}}' \
  --node-to-node-encryption-options '{"Enabled":true}' \
  --encryption-at-rest-options '{"Enabled":true}' \
  --domain-endpoint-options '{"EnforceHTTPS":true,"TLSSecurityPolicy":"Policy-Min-TLS-1-2-2019-07"}' \
  --identity-center-options '{"EnabledAPIAccess":true,"IdentityCenterInstanceARN":"arn:aws:sso:::instance/ssoins-{{instance-id}}","IdentityCenterInstanceRegion":"{{idc-region}}","RolesKey":"GroupId","SubjectKey":"UserId"}' \
  --access-policies '{"Version":"2012-10-17",		 	 	 "Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::{{account-id}}:role/{{NeoIdCAppRole}}"},"Action":"es:ESHttp*","Resource":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{vpc-domain-name}}/*"}]}' \
  --region {{target-region}}
```

続行する`Active`前に、ドメインのステータスが になるまで待ちます。

### ステップ 3: クロスリージョンサポート (ターゲットリージョン) を使用して OpenSearch UI サービスプリンシパルの VPC エンドポイントを承認する
<a name="cross-region-scenario-4-step-3"></a>

**重要**  
これは、クロスリージョンアクセスを持つ VPC ドメインに固有の重要なステップです。OpenSearch UI サービスには、VPC エンドポイントへのアクセスを明示的に許可し、アプリケーションリージョンを`SupportedRegions`リストに含める必要があります。

```
# Authorize the service principal with cross-region support
aws opensearch authorize-vpc-endpoint-access \
  --domain-name {{vpc-domain-name}} \
  --service "application.opensearchservice.amazonaws.com" \
  --service-options '{"SupportedRegions":["{{target-region}}","{{application-region}}"]}' \
  --region {{target-region}}

# Verify authorization
aws opensearch list-vpc-endpoint-access \
  --domain-name {{vpc-domain-name}} \
  --region {{target-region}}
```

予想されるレスポンス

```
{
  "AuthorizedPrincipalList": [
    {
      "PrincipalType": "AWS_SERVICE",
      "Principal": "application.opensearchservice.amazonaws.com",
      "ServiceOptions": {
        "SupportedRegions": ["{{target-region}}", "{{application-region}}"]
      }
    }
  ]
}
```

### ステップ 4: IAM Identity Center アプリケーションの IAM ロールを作成する
<a name="cross-region-scenario-4-step-4"></a>

OpenSearch UI が IAM Identity Center ユーザーデータプレーンアクセスに使用する IAM ロールを作成します。

**IAM Identity Center アプリケーションロールを作成するには**

1. `sts:AssumeRole` ステートメントのみを使用して信頼ポリシーを作成します。次のステップでアプリケーションを作成した後、このポリシーを更新して `sts:SetContext`ステートメントを追加します。

   ```
   {
     "Version": "2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": {
           "Service": "application.opensearchservice.amazonaws.com"
         },
         "Action": "sts:AssumeRole"
       }
     ]
   }
   ```

1. アクセス許可ポリシーを作成します。

   ```
   {
     "Version": "2012-10-17",		 	 	 
     "Statement": [{
       "Sid": "OpenSearchDomain",
       "Effect": "Allow",
       "Action": ["es:ESHttp*"],
       "Resource": "arn:aws:es:{{target-region}}:{{account-id}}:domain/{{vpc-domain-name}}/*"
     }]
   }
   ```

1. ロールを作成し、ポリシーをアタッチします。

   ```
   aws iam create-role \
     --role-name {{NeoIdCAppRole}} \
     --assume-role-policy-document file://{{neoidc-trust-policy.json}}
   
   aws iam put-role-policy \
     --role-name {{NeoIdCAppRole}} \
     --policy-name {{NeoIdCAppPermissions}} \
     --policy-document file://{{neoidc-permissions-policy.json}}
   ```

### ステップ 5: IAM アイデンティティセンターで OpenSearch UI アプリケーションを作成する (アプリケーションリージョン)
<a name="cross-region-scenario-4-step-5"></a>

```
aws opensearch create-application \
  --region {{application-region}} \
  --name "{{cross-region-vpc-idc-app}}" \
  --iam-identity-center-options '{
    "enabled":true,
    "iamIdentityCenterInstanceArn":"arn:aws:sso:::instance/ssoins-{{instance-id}}",
    "iamRoleForIdentityCenterApplicationArn":"arn:aws:iam::{{account-id}}:role/{{NeoIdCAppRole}}"
  }' \
  --data-sources '[{
    "dataSourceArn":"arn:aws:es:{{target-region}}:{{account-id}}:domain/{{vpc-domain-name}}",
    "dataSourceDescription":"{{Cross-region VPC domain}}"
  }]' \
  --app-configs '[{"key":"opensearchDashboards.dashboardAdmin.users","value":"[\"{{test-user}}\"]"}]'
```

アプリケーションを作成したら、レスポンスの SSO アプリケーション ID を書き留めます。次に、IAM Identity Center アプリケーションロールの信頼ポリシーを更新して、`sts:SetContext`ステートメントを追加します。

```
{
  "Version": "2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "application.opensearchservice.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    },
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "application.opensearchservice.amazonaws.com"
      },
      "Action": "sts:SetContext",
      "Condition": {
        "ForAllValues:ArnEquals": {
          "sts:RequestContextProviders": "arn:aws:iam::{{account-id}}:oidc-provider/portal.sso.{{idc-region}}.amazonaws.com/apl/{{application-id}}"
        }
      }
    }
  ]
}
```

```
aws iam update-assume-role-policy \
  --role-name {{NeoIdCAppRole}} \
  --policy-document file://{{updated-trust-policy.json}}
```

### ステップ 6: IAM Identity Center ユーザーとグループを作成して割り当てる
<a name="cross-region-scenario-4-step-6"></a>

ユーザー、グループ[ステップ 4: IAM Identity Center ユーザーとグループを作成して割り当てる](#cross-region-scenario-2-step-4)を作成し、アプリケーションに割り当て、ターゲットドメインでバックエンドロールマッピングを設定するには、 と同じ手順に従います。

### ステップ 7: 検証とアクセス
<a name="cross-region-scenario-4-step-7"></a>

アプリケーションの詳細を取得してエンドポイント URL を取得します。

```
aws opensearch get-application \
  --region {{application-region}} \
  --id {{application-id}}
```
+ アプリケーションエンドポイント URL に移動します。
+ IAM Identity Center ユーザー認証情報を使用してサインインします。
+ IAM Identity Center ユーザーのデータリクエストは、IAM Identity Center アプリケーションロールで署名されます。
+ ドメインコントロールデータアクセス許可のバックエンドロールマッピング。

## アプリケーションの管理
<a name="cross-region-managing-applications"></a>

**クロスリージョンデータソースを使用してアプリケーションを更新する**  
以下のコマンドを実行してください。{{プレースホルダー値}}を、ユーザー自身の情報に置き換えます。

```
aws opensearch update-application \
  --region {{application-region}} \
  --id {{application-id}} \
  --data-sources '[{
    "dataSourceArn":"arn:aws:es:{{target-region-1}}:{{account-id}}:domain/{{domain-1}}",
    "dataSourceDescription":"{{Domain in target Region 1}}"
  },{
    "dataSourceArn":"arn:aws:es:{{target-region-2}}:{{account-id}}:domain/{{domain-2}}",
    "dataSourceDescription":"{{Domain in target Region 2}}"
  }]'
```

**重要**  
更新オペレーションは、データソース配列全体を置き換えます。保持するすべてのデータソースを含めます。

**アプリケーションを一覧表示する**  
次のコマンドを実行します。

```
aws opensearch list-applications \
  --region {{application-region}}
```

**アプリケーションの削除**  
次のコマンドを実行します。

```
aws opensearch delete-application \
  --region {{application-region}} \
  --id {{application-id}}
```

**特定のリージョンの VPC エンドポイントアクセスを取り消す**  
他の を保持しながら特定の AWS リージョンのクロスリージョンアクセスを取り消すには、 `--service-options`パラメータをリージョンとともに使用して取り消します。

```
aws opensearch revoke-vpc-endpoint-access \
  --domain-name {{vpc-domain-name}} \
  --service "application.opensearchservice.amazonaws.com" \
  --service-options '{"SupportedRegions":["{{region-to-revoke}}"]}' \
  --region {{target-region}}
```

## クイックリファレンス
<a name="cross-region-quick-reference"></a>

次の表は、ドメインタイプ、認証方法、同一リージョンアクセスとクロスリージョンアクセスの主な違いをまとめたものです。


**VPC ドメインと比較したパブリックドメイン**  

| 側面 | パブリックドメイン | VPC ドメイン | 
| --- | --- | --- | 
| VPC エンドポイント認可 | 不要 | 必須 – application.opensearchservice.amazonaws.comで を承認する必要があります SupportedRegions | 
| ネットワーク設定 | なし | HTTPS (443) インバウンドの VPC、サブネット、セキュリティグループ | 
| IAM アクセスポリシー | 必須 | 必須 | 


**IAM ユーザーと IAM Identity Center ユーザーの比較**  

| 側面 | IAM ユーザー | IAM Identity Center ユーザー | 
| --- | --- | --- | 
| データプレーンの認証情報 | ユーザー独自の IAM 認証情報 | IAM Identity Center アプリケーションロール | 
| アクセスコントロール | ドメインアクセスポリシーとバックエンドロールマッピング | ドメインアクセスポリシーとバックエンドロールマッピング | 
| アプリケーションリージョンの制約 | 任意のリージョン | IAM Identity Center インスタンスと同じリージョンに存在する必要があります | 
| ドメイン設定 | 標準 | --identity-center-options で必要 IdentityCenterInstanceRegion | 
| 追加セットアップ | なし | IAM Identity Center アプリケーションロール、ユーザー/グループの作成、アプリケーションの割り当て、バックエンドロールマッピング | 


**同一リージョンとクロスリージョンの比較**  

| 側面 | 同一リージョン | クロスリージョン | 
| --- | --- | --- | 
| データソース ARN | アプリケーションと同じリージョン | アプリケーションとは異なるリージョン (同じパーティション) | 
| VPC エンドポイント認可 | 省略 --service-options | --service-options に を含める SupportedRegions | 
| IAM Identity Center ドメイン設定 | IdentityCenterInstanceRegion が任意 | IdentityCenterInstanceRegion が必須 | 
| クロスパーティションサポート | 該当なし | サポートされていない – データソースは同じパーティションに存在する必要があります | 

## 重要な注意事項
<a name="cross-region-important-notes"></a>
+ クロスリージョンデータソースの関連付けでは、ターゲットドメインできめ細かなアクセスコントロールを有効にする必要があります。
+ クロスリージョンデータソースは同じパーティション内にある必要があります。クロスパーティションアクセス ( から など`aws-cn`) `aws` はサポートされていません。
+ データソースリージョンは、データソース ARN から自動的に抽出されます。`CreateApplication` または `UpdateApplication` APIs では、追加のリージョンパラメータは必要ありません。
+ 同一アカウントのクロスリージョンデータソースの場合、 `iamRoleForDataSourceArn` は必要ありません。これは、クロスアカウントデータソースにのみ必要です。
+ VPC ドメインの場合は、 を呼び出すときに `SupportedRegions`パラメータにアプリケーションリージョンを含める必要があります`AuthorizeVpcEndpointAccess`。を省略すると、同じリージョンのアクセスのみが`--service-options`許可されます。
+ IAM Identity Center フローの場合、OpenSearch UI アプリケーションは IAM Identity Center インスタンスと同じリージョンに存在する必要があります。
+ クロスリージョンドメインを持つ IAM Identity Center フローの場合、クロスリージョントークンイントロスペクションを有効にする`--identity-center-options`には、ターゲットドメイン`IdentityCenterInstanceRegion`に を含める必要があります。
+ サポートされているエンジンバージョン: OpenSearch 1.3 以降。

## トラブルシューティング
<a name="cross-region-troubleshooting"></a>


| 問題 | 解決方法 | 
| --- | --- | 
| 「ドメインにアクセスできません」でアプリケーションの作成が失敗する | ドメインがターゲットリージョンに存在し、きめ細かなアクセスコントロールが有効になっていることを確認します。クロスアカウントシナリオでは、クロスアカウントロールに アクセスes:DescribeDomain許可があり、信頼ポリシーでソースアカウントが許可されていることを確認します。 | 
| クロスリージョンの VPC ドメインアクセスが失敗する | に含まれているアプリケーションリージョンapplication.opensearchservice.amazonaws.comを使用して、VPC エンドポイントが に対して承認されていることを確認しますSupportedRegions。 | 
| IAM ユーザーのデータプレーンアクセスが拒否されました | ターゲットドメインアクセスポリシーが IAM ユーザーまたはロールプリンシパルを許可し、きめ細かなアクセスコントロールバックエンドロールマッピングが適切なアクセス許可を付与していることを確認します。 | 
| IAM Identity Center ユーザーのデータプレーンアクセスが拒否されました | バックエンドロールマッピングに IAM Identity Center グループ ID が含まれ、ドメインポリシーIdentityCenterInstanceRegionで IAM Identity Center アプリケーションロールが許可され、ドメインの OpenSearch UI アプリケーションと同じリージョンに正しく設定されていることを確認します。 | 
| クロスパーティションデータソースが拒否されました | クロスパーティションアクセスはサポートされていません。データソース ARN がアプリケーションと同じパーティションにあることを確認します。 | 
| クロスリージョンドメインの IAM Identity Center 認証が失敗する | IdentityCenterInstanceRegion IAM Identity Center インスタンスが有効になっている正しいリージョンに が設定されていることを確認します。OpenSearch UI アプリケーションも同じリージョンに存在する必要があります。 | 