

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 亚马逊 Pi EventBridge pes 的目标
<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 主题（不支持 SNS FIFO 主题）
+ Amazon SQS 队列
+ [Step Functions 状态机](#pipes-targets-specifics-lambda-stepfunctions)
  + 快速工作流程（同步或异步）
  + 标准工作流程（异步）
+ [Timestream 用于 LiveAnalytics 桌子](#pipes-targets-specifics-timestream)

## 目标参数
<a name="pipes-targets-specific-parms"></a>

某些目标服务不向目标发送事件负载，而是将事件视为调用特定 API 的触发器。 EventBridge 使用来指定[https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html)向该 API 发送哪些信息。这些功能包括：
+ API 目标（发送到 API 目标的数据必须与 API 的结构相匹配。必须使用 [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 对象来确保数据的结构正确。如果要包含原始事件负载，请在 [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 中引用它。）
+ API Gateway（发送到 API Gateway 的数据必须与 API 的结构相匹配。必须使用 [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 对象来确保数据的结构正确。如果要包含原始事件负载，请在 [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetParameters.html#pipes-Type-PipeTargetParameters-InputTemplate) 中引用它。）
+ [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetRedshiftDataParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetRedshiftDataParameters.html)（Amazon Redshift 数据 API 集群）
+ [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetSageMakerPipelineParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetSageMakerPipelineParameters.html)（Amazon SageMaker 运行时模型构建管道）
+ [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetBatchJobParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetBatchJobParameters.html) (Amazon Batch)

**注意**  
EventBridge 不支持所有 JSON Path 语法并在运行时对其进行评估。支持的语法包括：  
点表示法（例如 `$.detail`）
短划线
下划线
字母数字字符
数组索引
通配符 (\$1)
向前斜杠

### 动态路径参数
<a name="pipes-targets-dynamic-parms"></a>

EventBridge 管道目标参数支持可选的动态 JSON 路径语法。您可以使用此语法指定 JSON 路径而不是静态值（例如 `$.detail.state`）。整个值必须是 JSON 路径，不能仅仅是其中的一部分。例如，`RedshiftParameters.Sql` 可以是 `$.detail.state` 但不能是 `"SELECT * FROM $.detail.state"`。这些路径在运行时会动态替换为来自指定路径的事件负载本身的数据。动态路径参数不能引用新值或输入转换生成的转换后的值。动态参数 JSON 路径支持的语法与转换输入时的语法相同。有关更多信息，请参阅 [Amazon Pip EventBridge es 输入转换](eb-pipes-input-transformation.md)。

动态语法可用于所有 Pip EventBridge es 丰富和目标参数的所有字符串、非枚举字段和目标参数，但以下除外：
+ [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetCloudWatchLogsParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetCloudWatchLogsParameters.html)
+ [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html)
+ [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeEnrichmentHttpParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeEnrichmentHttpParameters.html)
+ [https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetHttpParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetHttpParameters.html)

[例如，要将管道 Kinesis 目标设置为源事件中的自定义密钥，请设置。`PartitionKey` KinesisTargetParameter PartitionKey](https://docs.amazonaws.cn/)到：
+ `"$.data.someKey"`，适用于 Kinesis 源
+ `"$.body.someKey"`，适用于 Amazon SQS 源

然后，如果事件负载是有效的 JSON 字符串（例如）`{"someKey":"someValue"}`，则从 JSON 路径中 EventBridge 提取该值并将其用作目标参数。在此示例中， EventBridge 会将 Kinesis 设置`PartitionKey`为 “” *someValue*。

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

要对您拥有的资源进行 API 调用，Pi EventBridge pes 需要适当的权限。 EventBridge PIpes 使用您在管道上指定的 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.amazonaws.cn/step-functions/latest/dg/concepts-standard-vs-express.html)。

## 有效载荷大小限制
<a name="pipes-targets-payload-size"></a>

EventBridge Pipes 支持高达 6 MB 的有效负载。但是，有效负载大小限制由较小者决定：6 MB 的管道限制或目标服务的最大有效载荷大小。例如：
+ Lambda 函数支持最大 6 MB 的有效负载，因此以 Lambda 为目标的管道的有效限制为 6 MB。
+ EventBridge 事件总线支持最大 1 MB 的有效负载，因此针对事件总线的管道的有效限制为 1 MB。
+ Step Functions 状态机支持最大 256 KB 的有效负载，因此以 Step Functions 为目标的管道的有效限制为 256 KB。

配置管道时，请确保您的有效载荷大小（包括通过扩充或输入转换应用的任何变换）不超过目标的最大有效载荷大小。

## Amazon Batch 任务队列目标细节
<a name="pipes-targets-specifics-batch"></a>

所有 Amazon Batch `submitJob`参数都使用显式配置`BatchParameters`，与所有 Pipe 参数一样，这些参数可以使用传入事件负载的 JSON 路径进行动态配置。

## CloudWatch 日志组目标细节
<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 Pip EventBridge es 批处理和并发](eb-pipes-batching-concurrency.md)。

## Timestream 有关 LiveAnalytics 表格目标的详细信息
<a name="pipes-targets-specifics-timestream"></a>

将 for LiveAnalytics 表指定 Timestream 为管道目标时的注意事项包括：
+ 目前不支持 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.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html](https://docs.amazonaws.cn/eventbridge/latest/pipes-reference/API_PipeTargetEventBridgeEventBusParameters.html)用于配置事件`source`和`detail-type`字段。这两个字段都支持动态 JSON 路径语法，用于从事件负载中提取值。例如，设置`Source`为`$.body.source`或`DetailType`为`$.data.eventType`。您也可以使用输入转换器在事件结构放置到`detail`字段中之前对其进行修改。有关更多信息，请参阅 [Amazon Pip EventBridge es 输入转换](eb-pipes-input-transformation.md)。