Package software.amazon.awscdk.services.pipes.targets.alpha


@Stability(Experimental) package software.amazon.awscdk.services.pipes.targets.alpha

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.

 Queue sourceQueue;
 ApiDestination dest;
 
 
 ApiDestinationTarget apiTarget = new ApiDestinationTarget(dest);
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(apiTarget)
         .build();
 

The input to the target API destination can be transformed:

 Queue sourceQueue;
 ApiDestination dest;
 
 
 ApiDestinationTarget apiTarget = ApiDestinationTarget.Builder.create(dest)
         .inputTransformation(InputTransformation.fromObject(Map.of("body", "👀")))
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(apiTarget)
         .build();
 

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.

 Queue sourceQueue;
 LogGroup targetLogGroup;
 
 
 CloudWatchLogsTarget logGroupTarget = new CloudWatchLogsTarget(targetLogGroup);
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(logGroupTarget)
         .build();
 

The input to the target log group can be transformed:

 Queue sourceQueue;
 LogGroup targetLogGroup;
 
 
 CloudWatchLogsTarget logGroupTarget = CloudWatchLogsTarget.Builder.create(targetLogGroup)
         .inputTransformation(InputTransformation.fromObject(Map.of("body", "👀")))
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(logGroupTarget)
         .build();
 

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.

 Queue sourceQueue;
 EventBus targetEventBus;
 
 
 EventBridgeTarget eventBusTarget = new EventBridgeTarget(targetEventBus);
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(eventBusTarget)
         .build();
 

The input to the target event bus can be transformed:

 Queue sourceQueue;
 EventBus targetEventBus;
 
 
 EventBridgeTarget eventBusTarget = EventBridgeTarget.Builder.create(targetEventBus)
         .inputTransformation(InputTransformation.fromObject(Map.of("body", "👀")))
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(eventBusTarget)
         .build();
 

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.

 Queue sourceQueue;
 Stream targetStream;
 
 
 KinesisTarget streamTarget = KinesisTarget.Builder.create(targetStream)
         .partitionKey("pk")
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(streamTarget)
         .build();
 

The input to the target data stream can be transformed:

 Queue sourceQueue;
 Stream targetStream;
 
 
 KinesisTarget streamTarget = KinesisTarget.Builder.create(targetStream)
         .partitionKey("pk")
         .inputTransformation(InputTransformation.fromObject(Map.of("body", "👀")))
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(streamTarget)
         .build();
 

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.

 Queue sourceQueue;
 IFunction targetFunction;
 
 
 LambdaFunction pipeTarget = LambdaFunction.Builder.create(targetFunction).build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();
 

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.

 Queue sourceQueue;
 IFunction targetFunction;
 
 
 LambdaFunction pipeTarget = LambdaFunction.Builder.create(targetFunction)
         .invocationType(LambdaFunctionInvocationType.FIRE_AND_FORGET)
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();
 

The input to the target Lambda Function can be transformed:

 Queue sourceQueue;
 IFunction targetFunction;
 
 
 LambdaFunction pipeTarget = LambdaFunction.Builder.create(targetFunction)
         .inputTransformation(InputTransformation.fromObject(Map.of("body", "👀")))
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();
 

Amazon SageMaker Pipeline

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

 Queue sourceQueue;
 IPipeline targetPipeline;
 
 
 SageMakerTarget pipelineTarget = new SageMakerTarget(targetPipeline);
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipelineTarget)
         .build();
 

The input to the target pipeline can be transformed:

 Queue sourceQueue;
 IPipeline targetPipeline;
 
 
 SageMakerTarget pipelineTarget = SageMakerTarget.Builder.create(targetPipeline)
         .inputTransformation(InputTransformation.fromObject(Map.of("body", "👀")))
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipelineTarget)
         .build();
 

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.

 Queue sourceQueue;
 IStateMachine targetStateMachine;
 
 
 SfnStateMachine pipeTarget = SfnStateMachine.Builder.create(targetStateMachine).build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();
 

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

 Queue sourceQueue;
 IStateMachine targetStateMachine;
 
 
 SfnStateMachine pipeTarget = SfnStateMachine.Builder.create(targetStateMachine)
         .invocationType(StateMachineInvocationType.FIRE_AND_FORGET)
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();
 

The input to the target state machine can be transformed:

 Queue sourceQueue;
 IStateMachine targetStateMachine;
 
 
 SfnStateMachine pipeTarget = SfnStateMachine.Builder.create(targetStateMachine)
         .inputTransformation(InputTransformation.fromObject(Map.of("body", "<$.body>")))
         .invocationType(StateMachineInvocationType.FIRE_AND_FORGET)
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();
 

Amazon SQS Queue

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

 Queue sourceQueue;
 Queue targetQueue;
 
 
 SqsTarget pipeTarget = new SqsTarget(targetQueue);
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();
 

The target input can be transformed:

 Queue sourceQueue;
 Queue targetQueue;
 
 
 SqsTarget pipeTarget = SqsTarget.Builder.create(targetQueue)
         .inputTransformation(InputTransformation.fromObject(Map.of(
                 "SomeKey", DynamicInput.fromEventPath("$.body"))))
         .build();
 
 Pipe pipe = Pipe.Builder.create(this, "Pipe")
         .source(new SqsSource(sourceQueue))
         .target(pipeTarget)
         .build();