The CDK Construct Library for Amazon EventBridge Pipes Targets
Project description
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 Function
Amazon SQS
A SQS message queue can be used as a target for a pipe. Messages will be pushed to the queue.
# source_queue: sqs.Queue
# target_queue: sqs.Queue
pipe_target = targets.SqsTarget(target_queue)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
The target input can be transformed:
# source_queue: sqs.Queue
# target_queue: sqs.Queue
pipe_target = targets.SqsTarget(target_queue,
input_transformation=pipes.InputTransformation.from_object({
"SomeKey": pipes.DynamicInput.from_event_path("$.body")
})
)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
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.
# source_queue: sqs.Queue
# target_state_machine: sfn.IStateMachine
pipe_target = targets.SfnStateMachine(target_state_machine)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
Specifying the Invocation Type when the target State Machine is invoked:
# source_queue: sqs.Queue
# target_state_machine: sfn.IStateMachine
pipe_target = targets.SfnStateMachine(target_state_machine,
invocation_type=targets.StateMachineInvocationType.FIRE_AND_FORGET
)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
The input to the target State Machine can be transformed:
# source_queue: sqs.Queue
# target_state_machine: sfn.IStateMachine
pipe_target = targets.SfnStateMachine(target_state_machine,
input_transformation=pipes.InputTransformation.from_object({"body": "<$.body>"}),
invocation_type=targets.StateMachineInvocationType.FIRE_AND_FORGET
)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
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.
# source_queue: sqs.Queue
# target_function: lambda.IFunction
pipe_target = targets.LambdaFunction(target_function)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
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
.
# source_queue: sqs.Queue
# target_function: lambda.IFunction
pipe_target = targets.LambdaFunction(target_function,
invocation_type=targets.LambdaFunctionInvocationType.FIRE_AND_FORGET
)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
The input to the target Lambda Function can be transformed:
# source_queue: sqs.Queue
# target_function: lambda.IFunction
pipe_target = targets.LambdaFunction(target_function,
input_transformation=pipes.InputTransformation.from_object({"body": "👀"})
)
pipe = pipes.Pipe(self, "Pipe",
source=SomeSource(source_queue),
target=pipe_target
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-pipes-targets-alpha-2.151.1a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b4d2c9efc4716938dcecfc8f5d7b3f2f9127aa143a021a7afa5e26ebdaad0df |
|
MD5 | 28332a7ac63af93741a43e1f0230b841 |
|
BLAKE2b-256 | 61487da804fa32fcd238984e26a16ee02bc47b5fcfbc1a1f70bf4a65042593b6 |
Hashes for aws_cdk.aws_pipes_targets_alpha-2.151.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d428232e44d35d17d023718093c1c3fb8bddc867630b58986b802a9be19bae0 |
|
MD5 | 1353bef00fd1e166997dad169ed3488a |
|
BLAKE2b-256 | 2bae3c98e7326e542c70054219c52b0702d84a5d35649bb5f47dd9cb3a3ce3d2 |