CLI による処理 - Amazon Bedrock

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

CLI による処理

CLI を使用して最初のドキュメントを処理する

S3 バケットにファイルを入力する

BDA でドキュメントを処理する前に、まずドキュメントを S3 バケットにアップロードする必要があります。

[Syntax] (構文)

aws s3 cp <source> <target> [--options]

例:

aws s3 cp /local/path/document.pdf s3://my-bda-bucket/input/document.pdf

基本的な処理コマンド構造

invoke-data-automation-async コマンドを使用してファイルを処理します。

aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg" }' \ --output-configuration '{ "s3Uri": "s3://amzn-s3-demo-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"

高度な処理コマンド構造

時間セグメントを使用した動画処理

動画ファイルの場合、処理する時間セグメントを指定できます。

aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/video.mp4", "assetProcessingConfiguration": { "video": { "segmentConfiguration": { "timestampSegment": { "startTimeMillis": 0, "endTimeMillis": 300000 } } } } }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"

カスタムブループリントの使用

カスタムブループリントは、 コマンドで直接指定できます。

aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --blueprints '[ { "blueprintArn": "Amazon Resource Name (ARN)", "version": "1", "stage": "LIVE" } ]' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"

暗号化設定の追加

セキュリティを強化するために、暗号化設定を追加できます。

aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --encryption-configuration '{ "kmsKeyId": "Amazon Resource Name (ARN)", "kmsEncryptionContext": { "Department": "Finance", "Project": "DocumentProcessing" } }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"

イベント通知

処理完了の EventBridge 通知を有効にします。

aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --notification-configuration '{ "eventBridgeConfiguration": { "eventBridgeEnabled": true } }' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"

処理ステータスの確認

get-data-automation-status コマンドを使用して、処理ジョブのステータスを確認します。

aws bedrock-data-automation-runtime get-data-automation-status \ --invocation-arn "Amazon Resource Name (ARN)"

レスポンスには現在のステータスが含まれます。

{ "status": "COMPLETED", "creationTime": "2025-07-24T12:34:56.789Z", "lastModifiedTime": "2025-07-24T12:45:12.345Z", "outputLocation": "s3://my-bucket/output/abcd1234/" }

処理結果を取得する

S3 での出力ファイルの検索

S3 バケット内の出力ファイルを一覧表示します。

aws s3 ls s3://amzn-s3-demo-bucket/output/

ローカルマシンに結果をダウンロードします。

aws s3 cp s3://amzn-s3-demo-bucket/output/ ~/Downloads/bda-results/ --recursive

出力構造について

出力には通常、以下が含まれます。

  • standard-output.json: 標準抽出結果が含まれます

  • custom-output.json: カスタムブループリントの結果が含まれます

  • metadata.json: 処理メタデータと信頼スコアが含まれます

一般的なレスポンスフィールド

標準出力には通常、以下が含まれます。

  • extractedData: 抽出されたメイン情報

  • confidence: 抽出された各フィールドの信頼スコア

  • metadata: タイムスタンプやモデルの詳細を含む情報の処理

  • boundingBoxes: 検出された要素の場所情報 (有効になっている場合)

エラー処理とトラブルシューティング

一般的なエラーシナリオと解決策:

  • 無効な S3 URI: S3 バケットが存在し、適切なアクセス許可があることを確認します

  • data-automation-profile-arn の欠落: このパラメータはすべての処理リクエストに必要です

  • プロジェクトが見つかりません: プロジェクト ARN が正しく、プロジェクトが存在することを確認します

  • サポートされていないファイル形式: ファイル形式が BDA でサポートされていることを確認します

処理ジョブへのタグの追加

処理ジョブの整理と追跡に役立つタグを追加できます。

aws bedrock-data-automation-runtime invoke-data-automation-async \ --input-configuration '{ "s3Uri": "s3://my-bucket/document.pdf" }' \ --output-configuration '{ "s3Uri": "s3://my-bucket/output/" }' \ --data-automation-configuration '{ "dataAutomationProjectArn": "Amazon Resource Name (ARN)", "stage": "LIVE" }' \ --tags '[ { "key": "Department", "value": "Finance" }, { "key": "Project", "value": "InvoiceProcessing" } ]' \ --data-automation-profile-arn "Amazon Resource Name (ARN)"