

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

# CLI を介した処理
<a name="bda-document-processing-cli"></a>

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

**[Syntax]** (構文)

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

例:

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

------
#### [ Async ]

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

ファイルを処理するには、`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)"
```

------
#### [ Sync ]

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

ファイルを処理するには、`invoke-data-automation` コマンドを使用します。

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

**高度な処理コマンド構造**

S3 バケットへの出力

```
        aws bedrock-data-automation-runtime invoke-data-automation \
        --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)"
        --region "aws-region"   //document only
```

バイト入力を使用する

```
        aws bedrock-data-automation-runtime invoke-data-automation \
        --input-configuration '{
            "bytes": #blob input
        }' \
        --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)"
        --region "aws-region"
```

**注記**  
**バイト**  
base64 でエンコードされたドキュメントバイトの BLOB。バイトの BLOB で提供されるドキュメントの最大サイズは 50 MB です。タイプは Base64-encodedされたバイナリデータオブジェクトである必要があります。

**カスタムブループリントを使用する (イメージのみ)**

```
        aws bedrock-data-automation-runtime invoke-data-automation \
        --input-configuration '{
            "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg"
        }' \
        --blueprints '[{"blueprintArn": "Amazon Resource Name (ARN)", "version": "1", "stage": "LIVE" } ]' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
        --region "aws-region"
```

------