

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Amazon EventBridge 管道目標
<a name="eb-pipes-event-target"></a>

您可以將管道中的資料傳送至特定目標。在 EventBridge 中設定管道時，您可以設定下列目標：
+ [API 目標](eb-api-destinations.md)
+ [API Gateway](eb-api-gateway-target.md)
+ [批次任務佇列](#pipes-targets-specifics-batch)
+ [CloudWatch 日誌群組](#pipes-targets-specifics-cwl)
+ [ECS 任務](#pipes-targets-specifics-ecs-task)
+ [相同帳戶和地區中的事件匯流排](#pipes-targets-specifics-eventbridge)
+ Firehose 交付串流
+ Inspector 評估範本
+ Kinesis 串流
+ [Lambda 函數 (同步或非同步)](#pipes-targets-specifics-lambda-stepfunctions)
+ Redshift 叢集資料 API 查詢
+ SageMaker AI 管道
+ Amazon SNS 主題 (不支援 Amazon SNS FIFO 主題)
+ Amazon SQS 佇列
+ [Step Functions 狀態機器](#pipes-targets-specifics-lambda-stepfunctions)
  + 快速工作流程 (同步或非同步)
  + 標準工作流程 (非同步)
+ [Timestream for LiveAnalytics 資料表](#pipes-targets-specifics-timestream)

## 目標參數
<a name="pipes-targets-specific-parms"></a>

有些目標服務不會將事件裝載傳送至目標，而是將事件視為調用特定 API 的觸發器。EventBridge 樑會使用指定 [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html) 要傳送到該 API 的資訊。這些索引標籤包括以下項目：
+ API 目的地 (傳送至 API 目的地的資料必須與 API 的結構相符。您必須使用 [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 物件來確保資料結構正確。如果您想要包含原始事件裝載，請在 [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 中進行參考。)
+ API Gateway (傳送至 API Gateway 的資料必須與 API 的結構相符。您必須使用 [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 物件來確保資料結構正確。如果您想要包含原始事件裝載，請在中 [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 中進行參考。)
+ [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetRedshiftDataParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetRedshiftDataParameters.html) (Amazon Redshift 資料 API 叢集)
+ [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetSageMakerPipelineParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetSageMakerPipelineParameters.html) (Amazon SageMaker 執行期模型建置管道)
+ [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetBatchJobParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetBatchJobParameters.html) (AWS Batch)

**注意**  
EventBridge 不支援所有 JSON 路徑語法，並在執行期對其進行評估。支援的語法包括：  
點符號 (例如 `$.detail`)
破折號
底線
英數字元
陣列索引
萬用字元 (\*)
正斜線

### 動態路徑參數
<a name="pipes-targets-dynamic-parms"></a>

EventBridge 管道目標參數支援選用的動態 JSON 路徑語法。此語法可讓您指定 JSON 路徑，而非靜態值 (例如 `$.detail.state`)。整個值必須是 JSON 路徑，而不僅僅是其中的一部分。例如，`RedshiftParameters.Sql` 可以是 `$.detail.state` 但不能是 `"SELECT * FROM $.detail.state"`。這些路徑會在執行期以指定路徑中的事件裝載本身的資料動態取代。動態路徑參數無法參考輸入轉換所產生的新值或轉換值。動態參數 JSON 路徑支援的語法與轉換輸入時相同。如需詳細資訊，請參閱[Amazon EventBridge 管道輸入轉換](eb-pipes-input-transformation.md)。

動態語法可用於所有 EventBridge 管道擴充的所有字串、非列舉欄位和目標參數，但下列項目除外：
+ [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetCloudWatchLogsParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetCloudWatchLogsParameters.html)
+ [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html)
+ [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeEnrichmentHttpParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeEnrichmentHttpParameters.html)
+ [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetHttpParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetHttpParameters.html)

例如，若要將管道 Kinesis 目標的 `PartitionKey` 設定為來源事件中的自訂金鑰，請將 [KinesisTargetParameter.PartitionKey](https://docs.aws.amazon.com/) 設定為：
+ `"$.data.{{someKey}}"` 針對 Kinesis 來源
+ `"$.body.{{someKey}}"` 針對 Amazon SQS 來源

然後，如果事件掛載為有效 JSON 字串，例如 `{"{{someKey}}":"{{someValue}}"}`，EventBridge 會從 JSON 路徑擷取該值，並將其用作目標參數。在此範例中，EventBridge 會將 Kinesis `PartitionKey` 設定為 "{{someValue}}"。

## 許可
<a name="pipes-targets-permissions"></a>

為了能夠根據您所擁有的資源進行 API 呼叫，EventBridge 管道需要適當的許可。EventBridge 管道會使用您在管道上指定的 IAM 角色，以便使用 IAM 主體 `pipes.amazonaws.com` 進行擴充和鎖定目標呼叫。

## 調用目標
<a name="pipes-targets-invocation"></a>

EventBridge 有下列方法來調用目標：
+ **同步處理** (調用類型設定為 `REQUEST_RESPONSE`)：EventBridge 會先等待來自目標的回應，然後再繼續。
+ 以**非同步方式** (調用類型設定為 `FIRE_AND_FORGET`)：EventBridge 在繼續之前不會等待回應。

依預設，對於具有排序來源的管道，EventBridge 會同步調用目標，因為在繼續下一個事件之前需要來自目標的回應。

如果來源未強制執行訂單，例如標準 Amazon SQS 佇列，EventBridge 可以同步或非同步調用支援的目標。

使用 Lambda 函數和 Step Functions 狀態機器，您可以設定調用類型。

**注意**  
對於 Step Functions 狀態機器，必須以非同步方式調用[標準工作流程](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-standard-vs-express.html)。

## 承載大小限制
<a name="pipes-targets-payload-size"></a>

EventBridge 管道支援高達 6 MB 的承載。不過，有效承載大小限制取決於較小者：管道限制為 6 MB 或目標服務的最大承載大小。例如：
+ Lambda 函數支援高達 6 MB 的承載，因此目標為 Lambda 之管道的有效限制為 6 MB。
+ EventBridge 事件匯流排支援高達 1 MB 的承載，因此目標為事件匯流排之管道的有效限制為 1 MB。
+ Step Functions 狀態機器支援高達 256 KB 的承載，因此以 Step Functions 為目標的管道有效限制為 256 KB。

設定管道時，請確保承載大小不超過目標的最大承載大小，包括透過擴充或輸入轉換套用的任何轉換。

## AWS Batch 任務佇列以特定項目為目標
<a name="pipes-targets-specifics-batch"></a>

所有 AWS Batch `submitJob`參數都使用 明確設定`BatchParameters`，如同所有管道參數一樣，這些參數可以使用傳入事件承載的 JSON 路徑動態設定。

## CloudWatch Logs 群組目標詳細資訊
<a name="pipes-targets-specifics-cwl"></a>

無論您是否使用輸入轉換器，事件裝載都會用作日誌訊息。您可以在 `PipeTarget` 中通過 `CloudWatchLogsParameters` 設定 `Timestamp` (或明確 `LogStreamName` 的目的地)。對於所有管道參數，這些參數可以使用傳入事件有效負載的 JSON 路徑進行動態配置。

## Amazon ECS 任務目標詳細資訊
<a name="pipes-targets-specifics-ecs-task"></a>

所有 Amazon ECS `runTask` 參數都是透過 `EcsParameters` 明確設定的。對於所有管道參數，這些參數可以使用傳入事件有效負載的 JSON 路徑進行動態配置。

## Lambda 函數和 Step Functions 工作流程目標詳細資訊
<a name="pipes-targets-specifics-lambda-stepfunctions"></a>

Lambda 和 Step Functions 沒有批次 API。若要處理來自管道來源的批次事件，批次會轉換為 JSON 陣列，並以輸入的形式傳遞至 Lambda 或 Step Functions 數目標。如需詳細資訊，請參閱[Amazon EventBridge 管道批次處理和並行](eb-pipes-batching-concurrency.md)。

## Timestream for LiveAnalytics 資料表目標詳細資訊
<a name="pipes-targets-specifics-timestream"></a>

將 Timestream for LiveAnalytics 資料表指定為管道目標時的考量包括：
+ 目前不支援將 Apache Kafka 串流 （包括來自Amazon MSK 或第三方供應商的串流） 做為管道來源。
+ 如果您已指定 Kinesis 或 DynamoDB 串流做為管道來源，則必須指定重試嘗試次數。

  如需詳細資訊，請參閱[規劃管道設定](eb-pipes-create.md#pipes-configure-pipe-settings)。

## EventBridge 事件匯流排目標詳細資訊
<a name="pipes-targets-specifics-eventbridge"></a>

當您將 EventBridge 事件匯流排設定為管道目標時，來自管道的承載會自動放置在 EventBridge 事件的 `detail`區段中。使用 [https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html](https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html)設定事件的 `source`和 `detail-type` 欄位。這兩個欄位都支援動態 JSON 路徑語法，以從您的事件承載擷取值。例如，將 `Source` 設為 `$.body.source`或 `DetailType`設為 `$.data.eventType`。您也可以使用輸入轉換器來修改事件結構，再將其放置在 `detail`欄位中。如需詳細資訊，請參閱[Amazon EventBridge 管道輸入轉換](eb-pipes-input-transformation.md)。