Skip to content

Commit

Permalink
Rebase, update integration test, fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Sep 27, 2024
1 parent e0c5810 commit 4175eca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-pipes-targets-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,19 @@ const pipe = new pipes.Pipe(this, 'Pipe', {
target: eventBusTarget,
});
```

The input to the target event bus can be transformed:

```ts
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,
});
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha';
import { Pipe } from '@aws-cdk/aws-pipes-alpha';
// eslint-disable-next-line import/no-extraneous-dependencies
import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha';
import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as cdk from 'aws-cdk-lib';
import { EventBridgeTarget } from '../lib/event-bridge';
Expand All @@ -8,27 +10,8 @@ const stack = new cdk.Stack(app, 'aws-cdk-pipes-targets-event-bridge');
const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue');
const targetEventBus = new cdk.aws_events.EventBus(stack, 'TargetEventBus');

class TestSource implements ISource {
sourceArn: string;

constructor(private readonly queue: cdk.aws_sqs.Queue) {
this.queue = queue;
this.sourceArn = queue.queueArn;
}

bind(_pipe: IPipe): SourceConfig {
return {
sourceParameters: { sqsQueueParameters: { batchSize: 1 } },
};
}

grantRead(pipeRole: cdk.aws_iam.IRole): void {
this.queue.grantConsumeMessages(pipeRole);
}
}

new Pipe(stack, 'Pipe', {
source: new TestSource(sourceQueue),
source: new SqsSource(sourceQueue),
target: new EventBridgeTarget(targetEventBus, {}),
});

Expand Down

0 comments on commit 4175eca

Please # to comment.