From cb50b2042b75525295b4f5e228a2169b5231c3d0 Mon Sep 17 00:00:00 2001 From: Raphael Manke Date: Fri, 9 Feb 2024 21:54:41 +0100 Subject: [PATCH] Update README --- .../aws-pipes-targets-alpha/README.md | 36 ++++++++++++++++++- .../rosetta/default.ts-fixture | 30 ++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk/aws-pipes-targets-alpha/rosetta/default.ts-fixture diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/README.md b/packages/@aws-cdk/aws-pipes-targets-alpha/README.md index 86b4a3f1613ce..181dea564943e 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/README.md +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/README.md @@ -28,4 +28,38 @@ For more details see the service documentation: Pipe targets are the end point of a EventBridge Pipe. ### Amazon SQS -TODO \ No newline at end of file + +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 +}); +``` diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-pipes-targets-alpha/rosetta/default.ts-fixture new file mode 100644 index 0000000000000..dc155f40dc5d6 --- /dev/null +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/rosetta/default.ts-fixture @@ -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 + } +}