Package software.amazon.awscdk.services.pipes.targets.alpha
Amazon EventBridge Pipes Targets Construct Library
---
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 a EventBridge Pipe.
For more details see the service documentation:
Targets
Pipe targets are the end point of a EventBridge Pipe.
The following targets are supported:
targets.SqsTarget
: Send event source to a Queuetargets.SfnStateMachine
: Invoke a State Machine from an event sourcetargets.LambdaFunction
: Send event source to a Lambda Functiontargets.ApiDestinationTarget
: Send event source to an EventBridge API Destinationtargets.KinesisTarget
: Send event source to a Kinesis data stream
Amazon SQS
A SQS message queue can be used as a target for a pipe. Messages will be pushed to the queue.
Queue sourceQueue; Queue targetQueue; SqsTarget pipeTarget = new SqsTarget(targetQueue); Pipe pipe = Pipe.Builder.create(this, "Pipe") .source(new SomeSource(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 SomeSource(sourceQueue)) .target(pipeTarget) .build();
AWS Step Functions State Machine
A State Machine can be used as a target for a pipe. The State Machine will be invoked with the (enriched) source payload.
Queue sourceQueue; IStateMachine targetStateMachine; SfnStateMachine pipeTarget = SfnStateMachine.Builder.create(targetStateMachine).build(); Pipe pipe = Pipe.Builder.create(this, "Pipe") .source(new SomeSource(sourceQueue)) .target(pipeTarget) .build();
Specifying 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 SomeSource(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 SomeSource(sourceQueue)) .target(pipeTarget) .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) source payload.
Queue sourceQueue; IFunction targetFunction; LambdaFunction pipeTarget = LambdaFunction.Builder.create(targetFunction).build(); Pipe pipe = Pipe.Builder.create(this, "Pipe") .source(new SomeSource(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 SomeSource(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 SomeSource(sourceQueue)) .target(pipeTarget) .build();
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 Kinesis Data Stream
A 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();
-
ClassDescription(experimental) A EventBridge Pipes target that sends messages to an EventBridge API destination.(experimental) A fluent builder for
ApiDestinationTarget
.(experimental) EventBridge API destination target properties.A builder forApiDestinationTargetParameters
An implementation forApiDestinationTargetParameters
(experimental) An EventBridge Pipes target that sends messages to a Kinesis stream.(experimental) A fluent builder forKinesisTarget
.(experimental) Kinesis target properties.A builder forKinesisTargetParameters
An implementation forKinesisTargetParameters
(experimental) An EventBridge Pipes target that sends messages to an AWS Lambda Function.(experimental) A fluent builder forLambdaFunction
.(experimental) InvocationType for invoking the Lambda Function.(experimental) Parameters for the LambdaFunction target.A builder forLambdaFunctionParameters
An implementation forLambdaFunctionParameters
(experimental) An EventBridge Pipes target that sends messages to an AWS Step Functions State Machine.(experimental) A fluent builder forSfnStateMachine
.(experimental) Parameters for the SfnStateMachine target.A builder forSfnStateMachineParameters
An implementation forSfnStateMachineParameters
(experimental) A EventBridge Pipes target that sends messages to an SQS queue.(experimental) A fluent builder forSqsTarget
.(experimental) SQS target properties.A builder forSqsTargetParameters
An implementation forSqsTargetParameters
(experimental) InvocationType for invoking the State Machine.