17
17
<!-- END STABILITY BANNER-->
18
18
19
19
20
- EventBridge Pipes Targets let you create a target for a EventBridge Pipe.
20
+ EventBridge Pipes Targets let you create a target for an EventBridge Pipe.
21
21
22
- For more details see the service documentation:
23
-
24
- [ Documentation] ( https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes-event-target.html )
22
+ For more details see the [ service documentation] ( https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes-event-target.html ) .
25
23
26
24
## Targets
27
25
28
- Pipe targets are the end point of a EventBridge Pipe.
26
+ Pipe targets are the end point of an EventBridge Pipe. The following targets are supported:
27
+
28
+ * ` targets.ApiDestinationTarget ` : [ Send event source to an EventBridge API destination] ( #amazon-eventbridge-api-destination )
29
+ * ` targets.CloudWatchLogsTarget ` : [ Send event source to a CloudWatch Logs log group] ( #amazon-cloudwatch-logs-log-group )
30
+ * ` targets.EventBridgeTarget ` : [ Send event source to an EventBridge event bus] ( #amazon-eventbridge-event-bus )
31
+ * ` targets.KinesisTarget ` : [ Send event source to a Kinesis data stream] ( #amazon-kinesis-data-stream )
32
+ * ` targets.LambdaFunction ` : [ Send event source to a Lambda function] ( #aws-lambda-function )
33
+ * ` targets.SfnStateMachine ` : [ Invoke a Step Functions state machine from an event source] ( #aws-step-functions-state-machine )
34
+ * ` targets.SqsTarget ` : [ Send event source to an SQS queue] ( #amazon-sqs )
35
+
36
+ ### Amazon EventBridge API Destination
29
37
30
- The following targets are supported:
38
+ An EventBridge API destination can be used as a target for a pipe.
39
+ The API destination will receive the (enriched/filtered) source payload.
31
40
32
- 1 . ` targets.SqsTarget ` : [ Send event source to an SQS queue] ( #amazon-sqs )
33
- 2 . ` targets.SfnStateMachine ` : [ Invoke a State Machine from an event source] ( #aws-step-functions-state-machine )
34
- 3 . ` targets.LambdaFunction ` : [ Send event source to a Lambda function] ( #aws-lambda-function )
35
- 4 . ` targets.ApiDestinationTarget ` : [ Send event source to an EventBridge API destination] ( #amazon-eventbridge-api-destination )
36
- 5 . ` targets.KinesisTarget ` : [ Send event source to a Kinesis data stream] ( #amazon-kinesis-data-stream )
37
- 6 . ` targets.EventBridgeTarget ` : [ Send event source to an EventBridge event bus] ( #amazon-eventbridge-event-bus )
41
+ ``` ts
42
+ declare const sourceQueue: sqs .Queue ;
43
+ declare const dest: events .ApiDestination ;
44
+
45
+ const apiTarget = new targets .ApiDestinationTarget (dest );
38
46
39
- ### Amazon SQS
47
+ const pipe = new pipes .Pipe (this , ' Pipe' , {
48
+ source: new SqsSource (sourceQueue ),
49
+ target: apiTarget ,
50
+ });
51
+ ```
40
52
41
- A SQS message queue can be used as a target for a pipe. Messages will be pushed to the queue.
53
+ The input to the target API destination can be transformed:
42
54
43
55
``` ts
44
56
declare const sourceQueue: sqs .Queue ;
45
- declare const targetQueue : sqs . Queue ;
57
+ declare const dest : events . ApiDestination ;
46
58
47
- const pipeTarget = new targets .SqsTarget (targetQueue );
59
+ const apiTarget = new targets .ApiDestinationTarget (dest , {
60
+ inputTransformation: pipes .InputTransformation .fromObject ({ body: " 👀" }),
61
+ });
48
62
49
63
const pipe = new pipes .Pipe (this , ' Pipe' , {
50
64
source: new SqsSource (sourceQueue ),
51
- target: pipeTarget
65
+ target: apiTarget ,
52
66
});
53
67
```
54
68
55
- The target input can be transformed:
69
+ ### Amazon CloudWatch Logs Log Group
70
+
71
+ A CloudWatch Logs log group can be used as a target for a pipe.
72
+ The log group will receive the (enriched/filtered) source payload.
56
73
57
74
``` ts
58
75
declare const sourceQueue: sqs .Queue ;
59
- declare const targetQueue : sqs . Queue ;
76
+ declare const targetLogGroup : logs . LogGroup ;
60
77
61
- const pipeTarget = new targets .SqsTarget (targetQueue ,
62
- {
63
- inputTransformation: pipes .InputTransformation .fromObject (
64
- {
65
- " SomeKey" : pipes .DynamicInput .fromEventPath (' $.body' )
66
- })
67
- }
68
- );
78
+ const logGroupTarget = new targets .CloudWatchLogsTarget (targetLogGroup );
69
79
70
80
const pipe = new pipes .Pipe (this , ' Pipe' , {
71
81
source: new SqsSource (sourceQueue ),
72
- target: pipeTarget
82
+ target: logGroupTarget ,
73
83
});
74
84
```
75
85
76
- ### AWS Step Functions State Machine
86
+ The input to the target log group can be transformed:
87
+
88
+ ``` ts
89
+ declare const sourceQueue: sqs .Queue ;
90
+ declare const targetLogGroup: logs .LogGroup ;
91
+
92
+ const logGroupTarget = new targets .CloudWatchLogsTarget (targetLogGroup , {
93
+ inputTransformation: pipes .InputTransformation .fromObject ({ body: " 👀" }),
94
+ });
77
95
78
- A State Machine can be used as a target for a pipe. The State Machine will be invoked with the (enriched) source payload.
96
+ const pipe = new pipes .Pipe (this , ' Pipe' , {
97
+ source: new SqsSource (sourceQueue ),
98
+ target: logGroupTarget ,
99
+ });
100
+ ```
101
+
102
+ ### Amazon EventBridge Event Bus
103
+
104
+ An EventBridge event bus can be used as a target for a pipe.
105
+ The event bus will receive the (enriched/filtered) source payload.
79
106
80
107
``` ts
81
108
declare const sourceQueue: sqs .Queue ;
82
- declare const targetStateMachine : sfn . IStateMachine ;
109
+ declare const targetEventBus : events . EventBus ;
83
110
84
- const pipeTarget = new targets .SfnStateMachine ( targetStateMachine ,{} );
111
+ const eventBusTarget = new targets .EventBridgeTarget ( targetEventBus );
85
112
86
113
const pipe = new pipes .Pipe (this , ' Pipe' , {
87
114
source: new SqsSource (sourceQueue ),
88
- target: pipeTarget
115
+ target: eventBusTarget ,
89
116
});
90
117
```
91
118
92
- Specifying the Invocation Type when the target State Machine is invoked :
119
+ The input to the target event bus can be transformed :
93
120
94
121
``` ts
95
122
declare const sourceQueue: sqs .Queue ;
96
- declare const targetStateMachine : sfn . IStateMachine ;
123
+ declare const targetEventBus : events . EventBus ;
97
124
98
- const pipeTarget = new targets .SfnStateMachine (targetStateMachine ,
99
- {
100
- invocationType: targets .StateMachineInvocationType .FIRE_AND_FORGET ,
101
- }
102
- );
125
+ const eventBusTarget = new targets .EventBridgeTarget (targetEventBus , {
126
+ inputTransformation: pipes .InputTransformation .fromObject ({ body: " 👀" }),
127
+ });
103
128
104
129
const pipe = new pipes .Pipe (this , ' Pipe' , {
105
130
source: new SqsSource (sourceQueue ),
106
- target: pipeTarget
131
+ target: eventBusTarget ,
107
132
});
108
133
```
109
134
110
- The input to the target State Machine can be transformed:
135
+ ### Amazon Kinesis Data Stream
136
+
137
+ A Kinesis data stream can be used as a target for a pipe.
138
+ The data stream will receive the (enriched/filtered) source payload.
111
139
112
140
``` ts
113
141
declare const sourceQueue: sqs .Queue ;
114
- declare const targetStateMachine : sfn . IStateMachine ;
142
+ declare const targetStream : kinesis . Stream ;
115
143
116
- const pipeTarget = new targets .SfnStateMachine (targetStateMachine ,
117
- {
118
- inputTransformation: pipes .InputTransformation .fromObject ({ body: ' <$.body>' }),
119
- invocationType: targets .StateMachineInvocationType .FIRE_AND_FORGET ,
120
- }
121
- );
144
+ const streamTarget = new targets .KinesisTarget (targetStream , {
145
+ partitionKey: ' pk' ,
146
+ });
122
147
123
148
const pipe = new pipes .Pipe (this , ' Pipe' , {
124
149
source: new SqsSource (sourceQueue ),
125
- target: pipeTarget
150
+ target: streamTarget ,
151
+ });
152
+ ```
153
+
154
+ The input to the target data stream can be transformed:
155
+
156
+ ``` ts
157
+ declare const sourceQueue: sqs .Queue ;
158
+ declare const targetStream: kinesis .Stream ;
159
+
160
+ const streamTarget = new targets .KinesisTarget (targetStream , {
161
+ partitionKey: ' pk' ,
162
+ inputTransformation: pipes .InputTransformation .fromObject ({ body: " 👀" }),
163
+ });
164
+
165
+ const pipe = new pipes .Pipe (this , ' Pipe' , {
166
+ source: new SqsSource (sourceQueue ),
167
+ target: streamTarget ,
126
168
});
127
169
```
128
170
129
171
### AWS Lambda Function
130
172
131
- A Lambda Function can be used as a target for a pipe. The Lambda Function will be invoked with the (enriched) source payload.
173
+ A Lambda function can be used as a target for a pipe.
174
+ The Lambda function will be invoked with the (enriched/filtered) source payload.
132
175
133
176
``` ts
134
177
declare const sourceQueue: sqs .Queue ;
@@ -142,7 +185,7 @@ const pipe = new pipes.Pipe(this, 'Pipe', {
142
185
});
143
186
```
144
187
145
- 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 ` .
188
+ 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 ` .
146
189
147
190
``` ts
148
191
declare const sourceQueue: sqs .Queue ;
@@ -174,102 +217,92 @@ const pipe = new pipes.Pipe(this, 'Pipe', {
174
217
});
175
218
```
176
219
177
- ### Amazon EventBridge API Destination
220
+ ### AWS Step Functions State Machine
178
221
179
- An EventBridge API destination can be used as a target for a pipe.
180
- The API destination will receive the (enriched/filtered) source payload.
222
+ A Step Functions state machine can be used as a target for a pipe.
223
+ The state machine will be invoked with the (enriched/filtered) source payload.
181
224
182
225
``` ts
183
226
declare const sourceQueue: sqs .Queue ;
184
- declare const dest : events . ApiDestination ;
227
+ declare const targetStateMachine : sfn . IStateMachine ;
185
228
186
- const apiTarget = new targets .ApiDestinationTarget ( dest );
229
+ const pipeTarget = new targets .SfnStateMachine ( targetStateMachine ,{} );
187
230
188
231
const pipe = new pipes .Pipe (this , ' Pipe' , {
189
232
source: new SqsSource (sourceQueue ),
190
- target: apiTarget ,
233
+ target: pipeTarget
191
234
});
192
235
```
193
236
194
- The input to the target API destination can be transformed :
237
+ You can specify the invocation type when the target state machine is invoked :
195
238
196
239
``` ts
197
240
declare const sourceQueue: sqs .Queue ;
198
- declare const dest : events . ApiDestination ;
241
+ declare const targetStateMachine : sfn . IStateMachine ;
199
242
200
- const apiTarget = new targets .ApiDestinationTarget ( dest , {
201
- inputTransformation: pipes . InputTransformation . fromObject ({ body: " 👀 " }) ,
243
+ const pipeTarget = new targets .SfnStateMachine ( targetStateMachine , {
244
+ invocationType: targets . StateMachineInvocationType . FIRE_AND_FORGET ,
202
245
});
203
246
204
247
const pipe = new pipes .Pipe (this , ' Pipe' , {
205
248
source: new SqsSource (sourceQueue ),
206
- target: apiTarget ,
207
- });
208
- ```
209
-
210
- ### Amazon Kinesis Data Stream
211
-
212
- A data stream can be used as a target for a pipe. The data stream will receive the (enriched/filtered) source payload.
213
-
214
- ``` ts
215
- declare const sourceQueue: sqs .Queue ;
216
- declare const targetStream: kinesis .Stream ;
217
-
218
- const streamTarget = new targets .KinesisTarget (targetStream , {
219
- partitionKey: ' pk' ,
220
- });
221
-
222
- const pipe = new pipes .Pipe (this , ' Pipe' , {
223
- source: new SqsSource (sourceQueue ),
224
- target: streamTarget ,
249
+ target: pipeTarget
225
250
});
226
251
```
227
252
228
- The input to the target data stream can be transformed:
253
+ The input to the target state machine can be transformed:
229
254
230
255
``` ts
231
256
declare const sourceQueue: sqs .Queue ;
232
- declare const targetStream : kinesis . Stream ;
257
+ declare const targetStateMachine : sfn . IStateMachine ;
233
258
234
- const streamTarget = new targets .KinesisTarget (targetStream , {
235
- partitionKey: ' pk' ,
236
- inputTransformation: pipes .InputTransformation .fromObject ({ body: " 👀" }),
237
- });
259
+ const pipeTarget = new targets .SfnStateMachine (targetStateMachine ,
260
+ {
261
+ inputTransformation: pipes .InputTransformation .fromObject ({ body: ' <$.body>' }),
262
+ invocationType: targets .StateMachineInvocationType .FIRE_AND_FORGET ,
263
+ }
264
+ );
238
265
239
266
const pipe = new pipes .Pipe (this , ' Pipe' , {
240
267
source: new SqsSource (sourceQueue ),
241
- target: streamTarget ,
268
+ target: pipeTarget
242
269
});
243
270
```
244
271
245
- ### Amazon EventBridge Event Bus
272
+ ### Amazon SQS Queue
246
273
247
- An event bus can be used as a target for a pipe. The event bus will receive the (enriched/filtered) source payload.
274
+ An SQS queue can be used as a target for a pipe.
275
+ The queue will receive the (enriched/filtered) source payload.
248
276
249
277
``` ts
250
278
declare const sourceQueue: sqs .Queue ;
251
- declare const targetEventBus : events . EventBus ;
279
+ declare const targetQueue : sqs . Queue ;
252
280
253
- const eventBusTarget = new targets .EventBridgeTarget ( targetEventBus );
281
+ const pipeTarget = new targets .SqsTarget ( targetQueue );
254
282
255
283
const pipe = new pipes .Pipe (this , ' Pipe' , {
256
284
source: new SqsSource (sourceQueue ),
257
- target: eventBusTarget ,
285
+ target: pipeTarget
258
286
});
259
287
```
260
288
261
- The input to the target event bus can be transformed:
289
+ The target input can be transformed:
262
290
263
291
``` ts
264
292
declare const sourceQueue: sqs .Queue ;
265
- declare const targetEventBus : events . EventBus ;
293
+ declare const targetQueue : sqs . Queue ;
266
294
267
- const eventBusTarget = new targets .EventBridgeTarget (targetEventBus , {
268
- inputTransformation: pipes .InputTransformation .fromObject ({ body: " 👀" }),
269
- });
295
+ const pipeTarget = new targets .SqsTarget (targetQueue ,
296
+ {
297
+ inputTransformation: pipes .InputTransformation .fromObject (
298
+ {
299
+ " SomeKey" : pipes .DynamicInput .fromEventPath (' $.body' )
300
+ })
301
+ }
302
+ );
270
303
271
304
const pipe = new pipes .Pipe (this , ' Pipe' , {
272
305
source: new SqsSource (sourceQueue ),
273
- target: eventBusTarget ,
306
+ target: pipeTarget
274
307
});
275
308
```
0 commit comments