
Amazon OpenSearch Service Optimized engine で index を S3 Tables へ公開してみた
はじめに
2026年11月25日に、Amazon OpenSearch Service の Optimized engine で index を S3 Tables へ公開できる機能が発表されました。
公開した index は、自分の AWS アカウントの Apache Iceberg テーブルになり、DuckDB など Iceberg 対応のツールから照会できます。この記事では、domain の作成から index の公開、DuckDB での照会までを試します。
検証環境
- リージョン: 東京(ap-northeast-1)
- OpenSearch: OpenSearch_3.9(Optimized engine)
- インスタンス: or2.large.search × 1
- AWS CLI: 2.42.5(amazon/aws-cli イメージ)
- awscurl: 0.45(python:3.12-slim に pip install)
- DuckDB: 2.0.1(Python パッケージ。python:3.12-slim に pip install)
catalog publishing を有効にした domain の作成
発表では、ドキュメントの「Publishing indices to Amazon S3 Tables」が挙げられています。この記事では、そのドキュメントの catalog publishing(CatalogOptions と _catalog API)の手順で試しました。
catalog publishing を使えるのは、OpenSearch 3.9 以降の Optimized engine を使い、保存時暗号化を有効にした domain です。catalog publishing は、一度有効にすると無効に戻せません。
ドキュメントによると、domain の作成・更新時は es:CreateDomain または es:UpdateDomainConfig に加えて、次の S3 Tables の権限が必要です。
s3tables:CreateTableBucket
s3tables:TagResource
s3tables:ListTagsForResource
s3tables:GetTableBucketPolicy
s3tables:PutTableBucketPolicy
今回は、create-domain の --catalog-options で catalog publishing を有効にしました。Optimized domain にするには、あわせて --engine-mode OPTIMIZED と --use-case OBSERVABILITY を指定します。
aws opensearch create-domain \
--domain-name s3t-verify \
--engine-version OpenSearch_3.9 \
--engine-mode OPTIMIZED \
--use-case OBSERVABILITY \
--cluster-config InstanceType=or2.large.search,InstanceCount=1 \
--ebs-options EBSEnabled=true,VolumeType=gp3,VolumeSize=20 \
--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 file://access-policy.json \
--catalog-options '{"Enabled":true,"Catalog":{"ServiceManagedS3Tables":{}}}' \
--region ap-northeast-1
access-policy.json
指定したロールからの署名付きリクエストを許可するポリシーです。111122223333 には自分のアカウント ID を、<role-name> には呼び出しに使うロール名を入れます。
printf '%s' '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::111122223333:role/<role-name>"},"Action":"es:*","Resource":"arn:aws:es:ap-northeast-1:111122223333:domain/s3t-verify/*"}]}' > access-policy.json
CatalogOptions の State は、describe-domain-config で確認します。create-domain の約9分40秒後に取得した State は Processing で、その約9秒後に取得した State は Active でした。
aws opensearch describe-domain-config --domain-name s3t-verify --query DomainConfig.CatalogOptions --region ap-northeast-1
{
"Options": {
"Enabled": true,
"Catalog": {
"ServiceManagedS3Tables": {}
}
},
"Status": {
"CreationDate": "2026-11-28T05:33:00.495000+00:00",
"UpdateDate": "2026-11-28T05:42:35.527000+00:00",
"UpdateVersion": 12,
"State": "Active",
"PendingDeletion": false
}
}
そのアカウントとリージョンで初めて有効化すると、opensearch という名前の table bucket が作られます。この bucket はアカウントとリージョンごとに1つで、すべての domain が共有します。
aws s3tables list-table-buckets --region ap-northeast-1 --query 'tableBuckets[].{name:name,createdAt:createdAt}'
[
{
"name": "aws-cloudwatch",
"createdAt": "2026-06-30T01:33:22.950190+00:00"
},
{
"name": "aws-s3",
"createdAt": "2026-06-17T01:45:03.331293+00:00"
},
{
"name": "opensearch",
"createdAt": "2026-11-28T05:32:59.671187+00:00"
}
]
index template と data stream
公開できるのは append-only の index です。index template で append-only を有効にし、紐付け先のテーブル名を設定しておくと、新しく作られる backing index も同じテーブルに紐付きます。
次の内容を index-template.json として保存し、awscurl で渡します。
{
"index_patterns": ["web-logs*"],
"data_stream": {},
"template": {
"settings": {
"index.append_only.enabled": true,
"index.catalog.table": "web_logs",
"index.catalog.strict_mapping": true
}
}
}
awscurl -X PUT "https://<ドメインエンドポイント>/_index_template/web-logs" \
--service es --region ap-northeast-1 \
-H 'Content-Type: application/json' -d @index-template.json
続けて data stream を作成し、web ログ20件を投入しました。
awscurl -X PUT "https://<ドメインエンドポイント>/_data_stream/web-logs" \
--service es --region ap-northeast-1 -H 'Content-Type: application/json'
awscurl -X POST "https://<ドメインエンドポイント>/web-logs/_bulk?refresh=true" \
--service es --region ap-northeast-1 \
-H 'Content-Type: application/json' -d @bulk-web-logs.ndjson
bulk-web-logs.ndjson
{"create":{}}
{"@timestamp":"2026-11-28T05:00:00.000Z","service":{"name":"cart"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":20,"message":"GET /api/cart 200 20ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:01:00.000Z","service":{"name":"checkout"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":27,"message":"GET /api/checkout 200 27ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:02:00.000Z","service":{"name":"search"},"log":{"level":"WARN"},"http":{"status_code":200},"latency_ms":34,"message":"GET /api/search 200 34ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:03:00.000Z","service":{"name":"cart"},"log":{"level":"ERROR"},"http":{"status_code":500},"latency_ms":41,"message":"GET /api/cart 500 41ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:04:00.000Z","service":{"name":"checkout"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":48,"message":"GET /api/checkout 200 48ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:05:00.000Z","service":{"name":"search"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":55,"message":"GET /api/search 200 55ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:06:00.000Z","service":{"name":"cart"},"log":{"level":"WARN"},"http":{"status_code":200},"latency_ms":62,"message":"GET /api/cart 200 62ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:07:00.000Z","service":{"name":"checkout"},"log":{"level":"ERROR"},"http":{"status_code":500},"latency_ms":69,"message":"GET /api/checkout 500 69ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:08:00.000Z","service":{"name":"search"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":76,"message":"GET /api/search 200 76ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:09:00.000Z","service":{"name":"cart"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":83,"message":"GET /api/cart 200 83ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:10:00.000Z","service":{"name":"checkout"},"log":{"level":"WARN"},"http":{"status_code":200},"latency_ms":90,"message":"GET /api/checkout 200 90ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:11:00.000Z","service":{"name":"search"},"log":{"level":"ERROR"},"http":{"status_code":500},"latency_ms":97,"message":"GET /api/search 500 97ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:12:00.000Z","service":{"name":"cart"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":104,"message":"GET /api/cart 200 104ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:13:00.000Z","service":{"name":"checkout"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":111,"message":"GET /api/checkout 200 111ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:14:00.000Z","service":{"name":"search"},"log":{"level":"WARN"},"http":{"status_code":200},"latency_ms":118,"message":"GET /api/search 200 118ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:15:00.000Z","service":{"name":"cart"},"log":{"level":"ERROR"},"http":{"status_code":500},"latency_ms":125,"message":"GET /api/cart 500 125ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:16:00.000Z","service":{"name":"checkout"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":132,"message":"GET /api/checkout 200 132ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:17:00.000Z","service":{"name":"search"},"log":{"level":"INFO"},"http":{"status_code":200},"latency_ms":139,"message":"GET /api/search 200 139ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:18:00.000Z","service":{"name":"cart"},"log":{"level":"WARN"},"http":{"status_code":200},"latency_ms":146,"message":"GET /api/cart 200 146ms"}
{"create":{}}
{"@timestamp":"2026-11-28T05:19:00.000Z","service":{"name":"checkout"},"log":{"level":"ERROR"},"http":{"status_code":500},"latency_ms":153,"message":"GET /api/checkout 500 153ms"}
作成した data stream の backing index は、_data_stream で確認します。
awscurl -X GET "https://<ドメインエンドポイント>/_data_stream/web-logs" \
--service es --region ap-northeast-1 -H 'Content-Type: application/json'
{"data_streams":[{"name":"web-logs","timestamp_field":{"name":"@timestamp"},"indices":[{"index_name":".ds-web-logs-000001","index_uuid":"000010a2kpnWjbQkuLbeCdWQ4kaQ"}],"generation":1,"status":"YELLOW","template":"web-logs"}]}
投入後の _count は20です。
awscurl -X GET "https://<ドメインエンドポイント>/web-logs/_count" \
--service es --region ap-northeast-1 -H 'Content-Type: application/json'
{"count":20,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0}}
index の公開
公開は _publish で行います。パスは _catalog/<catalog 名>/<table 名>/<backing index 名>/_publish の形です。このパスには data stream 名を指定できないため、backing index 名を指定します。
catalog 名は、domain 名を小文字にして、ハイフンをアンダースコアに置き換えたものです。s3t-verify は s3t_verify になります。変換後の名前が aws で始まる場合と、末尾が _ になる場合は、前後が 0 で囲まれます(aws-logs は 0aws_logs0)。この名前は _catalog API のパスと、DuckDB の schema 名で使います。
awscurl -X POST "https://<ドメインエンドポイント>/_catalog/s3t_verify/web_logs/.ds-web-logs-000001/_publish?wait_for_completion=true" \
--service es --region ap-northeast-1 -H 'Content-Type: application/json'
{
"publish": {
"publish_id": "wvSnrFy9SZW4RiFRKD7dSw",
"catalog": "s3t_verify",
"table": "web_logs",
"indices": [".ds-web-logs-000001"],
"state": "SUCCESS",
"start_time_in_millis": 1795844598601,
"end_time_in_millis": 1795844600684,
"duration_in_millis": 2083,
"shards": { "total": 5, "successful": 5, "failed": 0 },
"files_added": 5,
"files_removed": 0,
"files_kept": 0,
"table_snapshot_id": 5420110035090429400
}
}
初回の公開時にテーブルが作成されます。応答の state が SUCCESS であれば、公開は完了しています。
公開後のテーブルの件数は、_stats で確認できます。
awscurl -X GET "https://<ドメインエンドポイント>/_catalog/s3t_verify/web_logs/_stats" \
--service es --region ap-northeast-1 -H 'Content-Type: application/json'
{
"catalog": "s3t_verify",
"table": "web_logs",
"exists": true,
"usage": {
"indices": {
"bound_total": 1,
"bound": [".ds-web-logs-000001"],
"published_total": 1,
"published": [".ds-web-logs-000001"]
}
},
"current": {
"snapshot_id": 5420110035090429400,
"last_updated_in_millis": 1795844601234,
"schema_id": 0,
"data_files": 5,
"delete_files": 0,
"records": 20,
"size_in_bytes": 24720
},
"history": { "snapshots": 1, "oldest_in_millis": 1795844601234 },
"publishes": {
"total": 1,
"success": 1,
"partial": 0,
"indices": 1,
"files": { "added": 5, "removed": 0, "kept": 0 },
"bytes_added_in_bytes": 24720,
"records_added": 20,
"first_in_millis": 1795844601234,
"last_in_millis": 1795844601234
}
}
S3 Tables 側のテーブルは、opensearch table bucket を対象に list-tables を実行して確認できます。
aws s3tables list-tables \
--table-bucket-arn arn:aws:s3tables:ap-northeast-1:111122223333:bucket/opensearch \
--region ap-northeast-1 \
--query 'tables[].{namespace:namespace,name:name,type:type}'
[
{
"namespace": [
"s3t_verify"
],
"name": "web_logs",
"type": "customer"
}
]
DuckDB での照会
公開されるテーブルは Iceberg v3 です。ドキュメントでは、Iceberg v3 を読めるエンジンとして、DuckDB 1.5.1 以降や Amazon EMR 7.12 以降の Apache Spark などが挙げられています。
次の内容を query.sql として保存します。111122223333 は自分のアカウント ID に置き換えます。認証情報には、環境変数に設定した一時認証情報を使いました。DuckDB は credential_chain プロバイダーでこれを読み込みます。テーブルは s3t.<catalog 名>.<table 名> の形で指定します。
INSTALL iceberg; LOAD iceberg; INSTALL httpfs; LOAD httpfs; INSTALL aws; LOAD aws;
CREATE SECRET (TYPE s3, PROVIDER credential_chain, REGION 'ap-northeast-1');
ATTACH 'arn:aws:s3tables:ap-northeast-1:111122223333:bucket/opensearch' AS s3t (TYPE iceberg, ENDPOINT_TYPE s3_tables);
SELECT version();
SELECT service.name AS service, count(*) AS requests, round(avg(latency_ms), 1) AS avg_latency_ms
FROM s3t.s3t_verify.web_logs
GROUP BY 1 ORDER BY 1;
Python の duckdb パッケージで、; で区切った文を順に実行しました。結果は次のとおりです。
| service | requests | avg_latency_ms |
|---|---|---|
| cart | 7 | 83.0 |
| checkout | 7 | 90.0 |
| search | 6 | 86.5 |
合計は20件で、サービスごとの件数と平均レイテンシも、投入データから手計算した値と一致しました。
まとめ
Amazon OpenSearch Service の Optimized engine から S3 Tables へ公開した index を、DuckDB で照会できることを確認しました。
OpenSearch Service の index を Iceberg テーブルとして照会したい場合は、S3 Tables と連携できる手段として、今回のアップデートをお試しください。








