亚马逊事件 Bridge 管道目标构建库
本单元中更高层次的构件的API是实验性的并正在积极开发中. 在今后任何版本中,它们都须作非背向相容的修改或去除。 这些是 不适用 语义版本 模型和断开的更改 在发行笔记中宣布. 这意味着虽然你可能使用它们,但可能需要更新 当更新到此软件包的更新版本时,您的源代码.
Event Bridge Pipes目标让你为EventBridge管道创建目标.
详情见 服务文件。 。 。 .
目标
管道目标是一个事件桥管的终点. 支持下列目标:
targets.ApiDestinationTarget数字 : 将事件源发送到 EventBridge API 目的地targets.ApiGatewayTarget数字 : 将事件源发送到 API Gateway REST APItargets.CloudWatchLogsTarget数字 : 将事件源发送给 Cloud Watch 日志组targets.EventBridgeTarget数字 : 将事件源发送到 EventBridge 事件总线targets.FirehoseTarget数字 : 将事件源发送到 Amazon 数据 Firehose 发送流targets.KinesisTarget数字 : 将事件源发送到 Kinesis 数据流targets.LambdaFunction数字 : 向 Lambda 函数发送事件源targets.SageMakerTarget数字 : 将事件源发送到 SageMaker 管道targets.SfnStateMachine数字 : 从事件源启动 Step 函数状态机targets.SnsTarget数字 : 向 SNS 专题发送事件源targets.SqsTarget数字 : 将事件源发送到 SQS 队列
亚马逊事件 Bridge API 目标
一个 EventBridge API 目的地可以作为管子的目标. API目的地将接收(浓缩/过滤)源有效载荷.
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 目的地的输入可以被转换:
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将接收(浓缩/过滤)源有效载荷.
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的输入可以被转换:
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,
});
亚马逊云表日志组
云表日志组可以作为管子的目标. 日志组将接收(浓缩/过滤)源有效载荷.
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,
});
对目标日志组的投入可以被转换:
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事件总线可用作管子的目标. 活动总线将接收(浓缩/过滤)源有效载荷.
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,
});
对目标事件总线的输入可以被转换:
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,
});
亚马逊数据火花快递流
亚马逊数据火花快递流可作为管子的目标. 输送流将接收(浓缩/过滤)源有效载荷.
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,
});
对目标交付流的投入可以被改变:
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数据流可以作为管子的目标. 数据流将接收(浓缩/过滤)源有效载荷.
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,
});
对目标数据流的输入可以被转换:
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函数将与(浓缩/过滤)源有效载荷一起被援引.
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。 。 。 .
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函数的输入可以被转换:
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输油管可用作管道的目标. 管道将接收(浓缩/过滤)源有效载荷.
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,
});
对目标管道的投入可以改变:
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 步骤函数状态机器
步态函数态机器可以用作管子的目标. 国产机器将与(浓缩/过滤)源有效载荷一起被援引.
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
});
您可以在引用目标状态机器时指定引用类型 :
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
});
对目标状态机器的输入可以被转换:
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主题可以被作为管子的目标. 该专题将获得(浓缩/过滤)源有效载荷.
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
});
目标输入可以被转换:
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队列可作为管子的目标. 队列将接收(浓缩/过滤)源有效载荷.
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
});
目标输入可以被转换:
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
});