@aws-cdk/aws-pipes-targets-alpha

中文文档
2.275.0-alpha.0发布于 2026/10/27Apache-2.0TypeScriptCommonJS零依赖近 30 天下载 4.3万

The CDK Construct Library for Amazon EventBridge Pipes Targets

原始使用文档
文档目录12 节
  1. Targets
  2. Amazon EventBridge API Destination
  3. Amazon API Gateway Rest API
  4. Amazon CloudWatch Logs Log Group
  5. Amazon EventBridge Event Bus
  6. Amazon Data Firehose Delivery Stream
  7. Amazon Kinesis Data Stream
  8. AWS Lambda Function
  9. Amazon SageMaker Pipeline
  10. AWS Step Functions State Machine
  11. Amazon SNS Topic
  12. Amazon SQS Queue

Amazon EventBridge Pipes Targets Construct Library


cdk-constructs: Experimental

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


EventBridge Pipes Targets let you create a target for an EventBridge Pipe.

For more details see the service documentation.

Targets

Pipe targets are the end point of an EventBridge Pipe. The following targets are supported:

Amazon EventBridge API Destination

An EventBridge API destination can be used as a target for a pipe. The API destination will receive the (enriched/filtered) source payload.

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,
});

The input to the target API destination can be transformed:

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 Gateway Rest API

A REST API can be used as a target for a pipe. The REST API will receive the (enriched/filtered) source payload.

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,
});

The input to the target REST API can be transformed:

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,
});

Amazon CloudWatch Logs Log Group

A CloudWatch Logs log group can be used as a target for a pipe. The log group will receive the (enriched/filtered) source payload.

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,
});

The input to the target log group can be transformed:

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,
});

Amazon EventBridge Event Bus

An EventBridge event bus can be used as a target for a pipe. The event bus will receive the (enriched/filtered) source payload.

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,
});

The input to the target event bus can be transformed:

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,
});

Amazon Data Firehose Delivery Stream

An Amazon Data Firehose delivery stream can be used as a target for a pipe. The delivery stream will receive the (enriched/filtered) source payload.

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,
});

The input to the target delivery stream can be transformed:

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,
});

Amazon Kinesis Data Stream

A Kinesis data stream can be used as a target for a pipe. The data stream will receive the (enriched/filtered) source payload.

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,
});

The input to the target data stream can be transformed:

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 Function

A Lambda function can be used as a target for a pipe. The Lambda function will be invoked with the (enriched/filtered) source payload.

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
});

The target Lambda function is invoked synchronously by default. You can also choose to invoke the Lambda Function asynchronously by setting invocationType property to FIRE_AND_FORGET.

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
});

The input to the target Lambda Function can be transformed:

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
});

Amazon SageMaker Pipeline

A SageMaker pipeline can be used as a target for a pipe. The pipeline will receive the (enriched/filtered) source payload.

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,
});

The input to the target pipeline can be transformed:

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 Step Functions State Machine

A Step Functions state machine can be used as a target for a pipe. The state machine will be invoked with the (enriched/filtered) source payload.

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
});

You can specify the invocation type when the target state machine is invoked:

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
});

The input to the target state machine can be transformed:

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
});

Amazon SNS Topic

An SNS topic can be used as a target for a pipe. The topic will receive the (enriched/filtered) source payload.

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
});

The target input can be transformed:

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
});

Amazon SQS Queue

An SQS queue can be used as a target for a pipe. The queue will receive the (enriched/filtered) source payload.

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
});

The target input can be transformed:

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 共发布 196 个版本,首次发布于 2024/02/15;过去 12 个月发布了 64 个版本。

版本发布日期距今
2.275.0-alpha.0latest2026/10/2712 天前
2.274.0-alpha.02026/10/2018 天前
2.273.0-alpha.02026/10/0930 天前
2.272.0-alpha.02026/09/301 个月前
2.271.0-alpha.02026/09/261 个月前
2.270.0-alpha.02026/09/181 个月前

关于 @aws-cdk/aws-pipes-targets-alpha 的常见问题

@aws-cdk/aws-pipes-targets-alpha 是什么?

The CDK Construct Library for Amazon EventBridge Pipes Targets

如何安装 @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 和提交记录判断。