# @aws-cdk/aws-pipes-targets-alpha 中文文档

规范地址：https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/

版本：2\.275\.0-alpha\.0
npm 元数据更新时间：2026-10-26T19:19:19.488Z
中文译文更新时间：2026-11-07T13:57:41.711Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40aws-cdk/aws-pipes-targets-alpha
原文对照：https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/?lang=original
项目主页：https://github.com/aws/aws-cdk
源码仓库：https://github.com/aws/aws-cdk

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：543 kB，37 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>= 20\.0\.0
- 运行依赖：0 个
- peer 依赖：constructs ^10\.5\.0，aws-cdk-lib ^2\.275\.0，@aws-cdk/aws-pipes-alpha 2\.275\.0-alpha\.0
- 首次发布：2024-02-14T23:24:41.420Z
- 最新版本发布：2026-10-26T19:19:19.028Z
- 近 30 天下载量：42760（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：196（近 12 个月 64 个）

## 中文简介

亚马逊事件管道目标 CDK 建构库

## 安装

```sh
npm install @aws-cdk/aws-pipes-targets-alpha
```

也可以使用：`pnpm add @aws-cdk/aws-pipes-targets-alpha`、`yarn add @aws-cdk/aws-pipes-targets-alpha`、`bun add @aws-cdk/aws-pipes-targets-alpha`

## README

# 亚马逊事件 Bridge 管道目标构建库

* * *

![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> 本单元中更高层次的构件的API是实验性的并正在积极开发中. 在今后任何版本中,它们都须作非背向相容的修改或去除。 这些是 不适用 [语义版本](https://semver.org/) 模型和断开的更改 在发行笔记中宣布. 这意味着虽然你可能使用它们,但可能需要更新 当更新到此软件包的更新版本时,您的源代码.

* * *

Event Bridge Pipes目标让你为EventBridge管道创建目标.

详情见 [服务文件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes-event-target.html)。 。 。 .

## 目标

管道目标是一个事件桥管的终点. 支持下列目标:

-   `targets.ApiDestinationTarget`数字 : [将事件源发送到 EventBridge API 目的地](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-eventbridge-api-destination)
-   `targets.ApiGatewayTarget`数字 : [将事件源发送到 API Gateway REST API](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-api-gateway-rest-api)
-   `targets.CloudWatchLogsTarget`数字 : [将事件源发送给 Cloud Watch 日志组](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-cloudwatch-logs-log-group)
-   `targets.EventBridgeTarget`数字 : [将事件源发送到 EventBridge 事件总线](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-eventbridge-event-bus)
-   `targets.FirehoseTarget`数字 : [将事件源发送到 Amazon 数据 Firehose 发送流](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-data-firehose-delivery-stream)
-   `targets.KinesisTarget`数字 : [将事件源发送到 Kinesis 数据流](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-kinesis-data-stream)
-   `targets.LambdaFunction`数字 : [向 Lambda 函数发送事件源](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-aws-lambda-function)
-   `targets.SageMakerTarget`数字 : [将事件源发送到 SageMaker 管道](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-sagemaker-pipeline)
-   `targets.SfnStateMachine`数字 : [从事件源启动 Step 函数状态机](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-aws-step-functions-state-machine)
-   `targets.SnsTarget`数字 : [向 SNS 专题发送事件源](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-sns-topic)
-   `targets.SqsTarget`数字 : [将事件源发送到 SQS 队列](https://npmcn.com/package/%40aws-cdk/aws-pipes-targets-alpha/#readme-amazon-sqs-queue)

### 亚马逊事件 Bridge API 目标

一个 EventBridge API 目的地可以作为管子的目标. API目的地将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const dest: events.ApiDestination;

const apiTarget = new targets.ApiDestinationTarget(dest);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: apiTarget,
});
```

对目标 API 目的地的输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const dest: events.ApiDestination;

const apiTarget = new targets.ApiDestinationTarget(dest, {
  inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: apiTarget,
});
```

### Amazon API 网关休息 API

一个REST API可以用作管子的目标. REST API将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;

const fn = new lambda.Function( this, 'MyFunc', {
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_LATEST,
  code: lambda.Code.fromInline( 'exports.handler = e => {}' ),
});

const restApi = new api.LambdaRestApi( this, 'MyRestAPI', { handler: fn } );
const apiTarget = new targets.ApiGatewayTarget(restApi);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: apiTarget,
});
```

对目标REST API的输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;

const fn = new lambda.Function( this, 'MyFunc', {
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_LATEST,
  code: lambda.Code.fromInline( 'exports.handler = e => {}' ),
});

const restApi = new api.LambdaRestApi( this, 'MyRestAPI', { handler: fn } );
const apiTarget = new targets.ApiGatewayTarget(restApi, {
  inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: apiTarget,
});
```

### 亚马逊云表日志组

云表日志组可以作为管子的目标. 日志组将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetLogGroup: logs.LogGroup;

const logGroupTarget = new targets.CloudWatchLogsTarget(targetLogGroup);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: logGroupTarget,
});
```

对目标日志组的投入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetLogGroup: logs.LogGroup;

const logGroupTarget = new targets.CloudWatchLogsTarget(targetLogGroup, {
  inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: logGroupTarget,
});
```

### 亚马逊事件Bridge事件巴士

EventBridge事件总线可用作管子的目标. 活动总线将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetEventBus: events.EventBus;

const eventBusTarget = new targets.EventBridgeTarget(targetEventBus);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: eventBusTarget,
});
```

对目标事件总线的输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetEventBus: events.EventBus;

const eventBusTarget = new targets.EventBridgeTarget(targetEventBus, {
  inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: eventBusTarget,
});
```

### 亚马逊数据火花快递流

亚马逊数据火花快递流可作为管子的目标. 输送流将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetDeliveryStream: firehose.DeliveryStream;

const deliveryStreamTarget = new targets.FirehoseTarget(targetDeliveryStream);

const pipe = new pipes.Pipe(this, 'Pipe', {
  source: new SqsSource(sourceQueue),
  target: deliveryStreamTarget,
});
```

对目标交付流的投入可以被改变:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetDeliveryStream: firehose.DeliveryStream;

const deliveryStreamTarget = new targets.FirehoseTarget(targetDeliveryStream, {
  inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
  source: new SqsSource(sourceQueue),
  target: deliveryStreamTarget,
});
```

### 亚马逊 Kinesis 数据流

一个Kinesis数据流可以作为管子的目标. 数据流将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetStream: kinesis.Stream;

const streamTarget = new targets.KinesisTarget(targetStream, {
    partitionKey: 'pk',
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: streamTarget,
});
```

对目标数据流的输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetStream: kinesis.Stream;

const streamTarget = new targets.KinesisTarget(targetStream, {
    partitionKey: 'pk',
    inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: streamTarget,
});
```

### AWS Lambda 函数

一个Lambda函数可以作为管子的目标. Lambda函数将与(浓缩/过滤)源有效载荷一起被援引.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetFunction: lambda.IFunction;

const pipeTarget = new targets.LambdaFunction(targetFunction,{});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

目标Lambda函数默认会同步被引用. 您也可以选择通过设置同步引用 Lambda 函数 `invocationType` 属性改为 `FIRE_AND_FORGET`。 。 。 .

```ts
declare const sourceQueue: sqs.Queue;
declare const targetFunction: lambda.IFunction;

const pipeTarget = new targets.LambdaFunction(targetFunction, {
  invocationType: targets.LambdaFunctionInvocationType.FIRE_AND_FORGET,
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

对目标Lambda函数的输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetFunction: lambda.IFunction;

const pipeTarget = new targets.LambdaFunction(targetFunction, {
  inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

### 亚马逊 SageMaker 管道

SageMaker输油管可用作管道的目标. 管道将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetPipeline: sagemaker.IPipeline;

const pipelineTarget = new targets.SageMakerTarget(targetPipeline);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipelineTarget,
});
```

对目标管道的投入可以改变:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetPipeline: sagemaker.IPipeline;

const pipelineTarget = new targets.SageMakerTarget(targetPipeline, {
  inputTransformation: pipes.InputTransformation.fromObject({ body: "👀" }),
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipelineTarget,
});
```

### AWS 步骤函数状态机器

步态函数态机器可以用作管子的目标. 国产机器将与(浓缩/过滤)源有效载荷一起被援引.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetStateMachine: sfn.IStateMachine;

const pipeTarget = new targets.SfnStateMachine(targetStateMachine,{});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

您可以在引用目标状态机器时指定引用类型 :

```ts
declare const sourceQueue: sqs.Queue;
declare const targetStateMachine: sfn.IStateMachine;

const pipeTarget = new targets.SfnStateMachine(targetStateMachine, {
    invocationType: targets.StateMachineInvocationType.FIRE_AND_FORGET,
});

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

对目标状态机器的输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetStateMachine: sfn.IStateMachine;

const pipeTarget = new targets.SfnStateMachine(targetStateMachine,
    {
      inputTransformation: pipes.InputTransformation.fromObject({ body: '<$.body>' }),
      invocationType: targets.StateMachineInvocationType.FIRE_AND_FORGET,
    }
);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

### 亚马逊 SNS 专题

SNS主题可以被作为管子的目标. 该专题将获得(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetTopic: sns.Topic;

const pipeTarget = new targets.SnsTarget(targetTopic);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

目标输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetTopic: sns.Topic;

const pipeTarget = new targets.SnsTarget(targetTopic,
    {
      inputTransformation: pipes.InputTransformation.fromObject( 
        { 
            "SomeKey": pipes.DynamicInput.fromEventPath('$.body')
        })
    }
);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

### 亚马逊 SQS 队列

SQS队列可作为管子的目标. 队列将接收(浓缩/过滤)源有效载荷.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetQueue: sqs.Queue;

const pipeTarget = new targets.SqsTarget(targetQueue);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

目标输入可以被转换:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetQueue: sqs.Queue;

const pipeTarget = new targets.SqsTarget(targetQueue,
    {
      inputTransformation: pipes.InputTransformation.fromObject(
        {
            "SomeKey": pipes.DynamicInput.fromEventPath('$.body')
        })
    }
);

const pipe = new pipes.Pipe(this, 'Pipe', {
    source: new SqsSource(sourceQueue),
    target: pipeTarget
});
```

## 常见问题

### @aws-cdk/aws-pipes-targets-alpha 是什么？

亚马逊事件管道目标 CDK 建构库

### 如何安装 @aws-cdk/aws-pipes-targets-alpha？

在项目目录运行 npm install @aws-cdk/aws-pipes-targets-alpha，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：constructs（^10\.5\.0）、aws-cdk-lib（^2\.275\.0）、@aws-cdk/aws-pipes-alpha（2\.275\.0-alpha\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @aws-cdk/aws-pipes-targets-alpha 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @aws-cdk/aws-pipes-targets-alpha 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @aws-cdk/aws-pipes-targets-alpha 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>= 20\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @aws-cdk/aws-pipes-targets-alpha 可以商用吗？

@aws-cdk/aws-pipes-targets-alpha 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @aws-cdk/aws-pipes-targets-alpha 的下载量有多少？

根据 npm 官方下载统计，@aws-cdk/aws-pipes-targets-alpha 在 2026/10/08 – 2026/11/06 这 30 天内被下载 42,760 次，日均约 1,425 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @aws-cdk/aws-pipes-targets-alpha 还在维护吗？

最新版本 2\.275\.0-alpha\.0 发布于 2026/10/27（12 天前）；至今共发布 196 个版本，其中过去 12 个月发布了 64 个；首次发布于 2024/02/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

