0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenSearch アプリケーション(UI)でブラウザからVPC環境下のOpenSearch Serviceを操作しよう

Posted at

はじめに

VPC環境下の作成したOpenSearch Serviceドメインのダッシュボードにアクセスする方法は複数ありますが、どの方法も踏み台のEC2が必要だったり、OpenSearch以外のリソース管理課金が発生します。
昨年の11月にリリースされたOpenSearch アプリケーション(UI)を使うことで、OpenSearchダッシュボードと同様にブラウザからGUIベースでクラスターの操作が可能になります。

OpenSearchアプリケーションの認証方法

OpenSearchアプリケーションの認証方法として、IAMと IAM Identity Centerをサポートしています。
今回はIAMユーザーを作成してOpenSearch アプリケーションにログインします。

OpenSearch Serviceドメイン作成

事前準備として、接続先のOpenSearch ServiceドメインをVPCに作成しておきます。
作成する際にきめ細かなアクセスコントロールの有効化とマスターユーザーとしてIAMユーザーを指定しておきます。

スクリーンショット 2025-03-03 16.39.22.png

AWS CLIのバージョン

最新版のAWS CLIを使用します。

コマンド
aws --version

結果(例):

 aws-cli/2.24.15 Python/3.12.9 Darwin/24.3.0 exe/x86_64

OpenSearchアプリケーション作成

app-configsオプションのvalueでIAMユーザーのARNを指定します。

コマンド
aws opensearch create-application \
 --name opensearch-app \
 --app-configs "
        {
        \"key\":\"opensearchDashboards.dashboardAdmin.users\",
        \"value\":\"arn:aws:iam::xxxxxxxxxxx:user/opensearch_ui\"
        }
    "

結果(例):

{
    "id": "8y75shjdhb4u5gqf159h",
    "name": "opensearch-app",
    "arn": "arn:aws:opensearch:ap-northeast-1:xxxxxxx:application/8y75shjdhb4u5gqf159h",
    "appConfigs": [
        {
            "key": "opensearchDashboards.dashboardAdmin.users",
            "value": "arn:aws:iam::xxxxxxx:user/opensearch_ui"
        }
    ],
    "createdAt": "2025-03-04T17:21:42.371000+09:00"
}

アプリケーションのidを控えておきましょう。

コマンド
aws opensearch list-applications --query 'ApplicationSummaries[].id' --output text

結果(例):

8y75shjdhb4u5gqf159h

データソース追加

data-sourcesオプションでOpenSearchのARNを指定します。
idオプションに先ほど控えておいたアプリケーションのidを指定します。

コマンド
aws opensearch update-application \
      --id 8y75shjdhb4u5gqf159h \
      --data-sources "[{\"dataSourceArn\": \"arn:aws:es:ap-northeast-1:xxxxxxxxx:domain/uitest\"}]"

結果(例):

{
    "id": "8y75shjdhb4u5gqf159h",
    "name": "opensearch-app",
    "arn": "arn:aws:opensearch:ap-northeast-1:xxxxxxx:application/8y75shjdhb4u5gqf159h",
    "dataSources": [
        {
            "dataSourceArn": "arn:aws:es:ap-northeast-1:xxxxxxxx:domain/uitest"
        }
    ],
    "appConfigs": [
        {
            "key": "opensearchDashboards.dashboardAdmin.users",
            "value": "arn:aws:iam::xxxxxxxxxx:user/opensearch_ui"
        }
    ],
    "createdAt": "2025-03-04T17:21:42.371000+09:00",
    "lastUpdatedAt": "2025-03-04T17:22:21.507000+09:00"
}

VPCエンドポイントアクセスの承認

OpenSearchドメインにVPCアクセスするプリンシパルを登録します。
ここではOpenSearchアプリケーションを認可するプリンシパルとして登録します。

コマンド
aws opensearch authorize-vpc-endpoint-access \
 --domain-name uitest \
 --service application.opensearchservice.amazonaws.com \
 --region ap-northeast-1

結果(例):

{
    "AuthorizedPrincipal": {
        "PrincipalType": "AWS Service",
        "Principal": "application.opensearchservice.amazonaws.com"
    }
}

これで接続の準備が整いました。

OpenSearchアプリケーションにログイン

マスターユーザーに指定したIAMユーザーでOpenSearchアプリケーションにログインしてみましょう

スクリーンショット 2025-03-04 16.43.01.png

ログインできました。
スクリーンショット 2025-03-04 16.43.32.png

動作確認

簡単なクエリを叩いてOpenSearchドメインへの接続に問題がないか確認してみます。
ログイン画面左下の「Dev Tools」をクリックします。
スクリーンショット 2025-03-04 16.59.40.png

クエリも実行できています。
スクリーンショット 2025-03-04 17.02.31.png

続いて、画面左下の[Data administration]をクリックします。
スクリーンショット 2025-03-04 17.41.11.png

Indexの確認、ユーザー権限管理といったドメイン管理に必要な操作が可能です。
スクリーンショット 2025-03-04 17.44.42.png

さいごに

追加料金なしで気軽にダッシュボード操作可能になったのは嬉しいですね。
クエリの発行も可能なのでローカルのダッシュボードの代替としても十分に思いました。今回はCLIで操作しましたが、マネジメントコンソールでの追加作業も容易でした。
本来はワークスペース上で提供されるオブザービリティやセキュリティ分析機能がメインの機能とされているようなので、別の機会で触れてみたいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?