Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelManke committed Feb 9, 2024
1 parent 676b955 commit cb50b20
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
36 changes: 35 additions & 1 deletion packages/@aws-cdk/aws-pipes-targets-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,38 @@ For more details see the service documentation:
Pipe targets are the end point of a EventBridge Pipe.

### Amazon SQS
TODO

A SQS message queue can be used as a target for a pipe. Messages will be pushed to the queue.

```ts
declare const sourceQueue: sqs.Queue;
declare const targetQueue: sqs.Queue;

const pipeTarget = new targets.SqsTarget(targetQueue);

const pipe = new pipes.Pipe(this, 'Pipe', {
source: new SomeSource(sourceQueue),
target: pipeTarget
});
```

The target configuration can be transformed:

```ts
declare const sourceQueue: sqs.Queue;
declare const targetQueue: sqs.Queue;

const pipeTarget = new targets.SqsTarget(targetQueue,
{
inputTransformation: pipes.InputTransformation.fromObject(
{
"SomeKey": pipes.DynamicInput.fromEventPath('$.body')
})
}
);

const pipe = new pipes.Pipe(this, 'Pipe', {
source: new SomeSource(sourceQueue),
target: pipeTarget
});
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Fixture with packages imported, but nothing else
import * as cdk from 'aws-cdk-lib';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { Construct } from 'constructs';
import * as pipes from '@aws-cdk/aws-pipes-alpha';
import * as targets from '@aws-cdk/aws-pipes-targets-alpha';

class SomeSource implements pipes.ISource {
sourceArn: string;
sourceParameters = undefined;
constructor(private readonly queue: sqs.Queue) {
this.queue = queue;
this.sourceArn = queue.queueArn;
}
bind(_pipe: pipes.IPipe): pipes.SourceConfig {
return {
sourceParameters: this.sourceParameters,
};
}
grantRead(pipeRole: cdk.aws_iam.IRole): void {
this.queue.grantConsumeMessages(pipeRole);
}
}

class Fixture extends cdk.Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
/// here
}
}

0 comments on commit cb50b20

Please sign in to comment.