diff --git a/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.dynamodb.ts b/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.dynamodb.ts index f440c77625976..0f7a763ec67d0 100644 --- a/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.dynamodb.ts +++ b/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.dynamodb.ts @@ -17,6 +17,8 @@ const table = new ddb.TableV2(stack, 'MyTable', { const dlqQueue = new cdk.aws_sqs.Queue(stack, 'DlqQueue'); const targetQueue = new cdk.aws_sqs.Queue(stack, 'TargetQueue'); +// When this module is promoted from alpha, TestTarget should +// be replaced with SqsTarget from @aws-cdk/aws-pipes-targets-alpha class TestTarget implements ITarget { targetArn: string; diff --git a/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.kinesis.ts b/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.kinesis.ts index c2e3d8c60b588..7d771b9e36bc5 100644 --- a/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.kinesis.ts +++ b/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.kinesis.ts @@ -9,6 +9,8 @@ const stack = new cdk.Stack(app, 'aws-cdk-pipes-sources-kinesis'); const sourceKinesisStream = new cdk.aws_kinesis.Stream(stack, 'SourceKinesisStream'); const targetQueue = new cdk.aws_sqs.Queue(stack, 'TargetQueue'); +// When this module is promoted from alpha, TestTarget should +// be replaced with SqsTarget from @aws-cdk/aws-pipes-targets-alpha class TestTarget implements ITarget { targetArn: string; diff --git a/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.sqs.ts b/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.sqs.ts index 346e98751b791..c31a3daf720f7 100644 --- a/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.sqs.ts +++ b/packages/@aws-cdk/aws-pipes-sources-alpha/test/integ.sqs.ts @@ -9,6 +9,8 @@ const stack = new cdk.Stack(app, 'aws-cdk-pipes-sources-sqs'); const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue'); const targetQueue = new cdk.aws_sqs.Queue(stack, 'TargetQueue'); +// When this module is promoted from alpha, TestTarget should +// be replaced with SqsTarget from @aws-cdk/aws-pipes-targets-alpha class TestTarget implements ITarget { targetArn: string; inputTransformation: InputTransformation = InputTransformation.fromEventPath('$.body'); diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/package.json b/packages/@aws-cdk/aws-pipes-targets-alpha/package.json index f51ecef876d3f..1ff59f74dc7a6 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/package.json +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/package.json @@ -89,8 +89,7 @@ "aws-cdk-lib": "0.0.0", "constructs": "^10.0.0", "@aws-cdk/aws-pipes-alpha": "0.0.0", - "@aws-cdk/integ-tests-alpha": "0.0.0", - "@aws-cdk/aws-pipes-sources-alpha": "0.0.0" + "@aws-cdk/integ-tests-alpha": "0.0.0" }, "dependencies": {}, "peerDependencies": { diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.api-destination.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.api-destination.ts index 51468d4b63500..17454520f7333 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.api-destination.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.api-destination.ts @@ -1,5 +1,4 @@ -import { Pipe } from '@aws-cdk/aws-pipes-alpha'; -import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha'; +import { IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2'; @@ -19,6 +18,25 @@ const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue'); * --> API Gateway HTTP API --> Lambda function */ +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + const fn = new lambda.Function(stack, 'ConnectHandler', { runtime: lambda.Runtime.NODEJS_LATEST, handler: 'index.handler', @@ -53,7 +71,7 @@ const destination = new cdk.aws_events.ApiDestination(stack, 'MyDestination', { }); new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new ApiDestinationTarget(destination, { headerParameters: { 'x-header': 'myheader', diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.cloudwatch-logs.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.cloudwatch-logs.ts index 503dcbc3aee49..3eae628c41e35 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.cloudwatch-logs.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.cloudwatch-logs.ts @@ -1,5 +1,4 @@ -import { InputTransformation, Pipe } from '@aws-cdk/aws-pipes-alpha'; -import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha'; +import { InputTransformation, IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import { CloudWatchLogsTarget } from '../lib'; @@ -18,13 +17,32 @@ const targetLogGroup = new cdk.aws_logs.LogGroup(stack, 'TargetLogGroup'); const logStreamName = 'Mexico'; const body = 'Cozumel'; +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + new cdk.aws_logs.LogStream(stack, 'TargetLogStream', { logGroup: targetLogGroup, logStreamName: logStreamName, }); new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new CloudWatchLogsTarget(targetLogGroup, { logStreamName, inputTransformation: InputTransformation.fromEventPath('$.body'), diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.event-bridge.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.event-bridge.ts index efa5fb85d23f4..2546569e3f101 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.event-bridge.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.event-bridge.ts @@ -1,5 +1,4 @@ -import { Pipe } from '@aws-cdk/aws-pipes-alpha'; -import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha'; +import { IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import { EventBridgeTarget } from '../lib/event-bridge'; @@ -9,8 +8,27 @@ 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'); +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new EventBridgeTarget(targetEventBus, {}), }); diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.kinesis.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.kinesis.ts index 13ff7777cf958..ed109c4bf71ee 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.kinesis.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.kinesis.ts @@ -1,5 +1,4 @@ -import { Pipe } from '@aws-cdk/aws-pipes-alpha'; -import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha'; +import { IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import { KinesisTarget } from '../lib/kinesis'; @@ -9,8 +8,27 @@ const stack = new cdk.Stack(app, 'aws-cdk-pipes-targets-kinesis'); const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue'); const targetStream = new cdk.aws_kinesis.Stream(stack, 'TargetStream'); +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new KinesisTarget(targetStream, { partitionKey: 'pk', }), diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.lambda.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.lambda.ts index 6f8afe6b8376b..8c4d8f863fdfe 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.lambda.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.lambda.ts @@ -1,7 +1,6 @@ import { randomUUID } from 'crypto'; import * as path from 'path'; -import { Pipe } from '@aws-cdk/aws-pipes-alpha'; -import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha'; +import { IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import * as iam from 'aws-cdk-lib/aws-iam'; @@ -20,6 +19,25 @@ const app = new cdk.App(); const stack = new cdk.Stack(app, 'aws-cdk-pipes-lambda-target'); const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue'); +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + const functionName = 'TestCdkPipesTargetLambdaFunction'; const targetFunction = new lambda.Function(stack, 'TargetLambdaFunction', { code: lambda.AssetCode.fromAsset( @@ -40,7 +58,7 @@ targetFunction.addToRolePolicy( ); new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new LambdaFunction(targetFunction, {}), }); diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sagemaker.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sagemaker.ts index 5a9e459dec879..13e06e573522f 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sagemaker.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sagemaker.ts @@ -1,6 +1,4 @@ -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 { IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import * as iam from 'aws-cdk-lib/aws-iam'; @@ -20,6 +18,25 @@ const app = new cdk.App(); const stack = new cdk.Stack(app, 'aws-cdk-pipes-targets-sagemaker'); const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue'); +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + interface FakePipelineProps { readonly pipelineName: string; } @@ -122,7 +139,7 @@ const targetPipeline = new FakePipeline(stack, 'Pipeline', { }); new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new SageMakerTarget(targetPipeline, { pipelineParameters: { foor: 'bar', diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sqs.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sqs.ts index eb7bbab00d627..4eb9f9dffab1c 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sqs.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.sqs.ts @@ -1,6 +1,5 @@ import { randomUUID } from 'crypto'; -import { InputTransformation, Pipe } from '@aws-cdk/aws-pipes-alpha'; -import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha'; +import { InputTransformation, IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import { SqsTarget } from '../lib'; @@ -10,8 +9,27 @@ const stack = new cdk.Stack(app, 'aws-cdk-pipes-targets'); const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue'); const targetQueue = new cdk.aws_sqs.Queue(stack, 'TargetQueue'); +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new SqsTarget(targetQueue, { inputTransformation: InputTransformation.fromEventPath('$.body'), diff --git a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.stepfunctions.ts b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.stepfunctions.ts index 10f3fe44a0b67..34caa42815871 100644 --- a/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.stepfunctions.ts +++ b/packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.stepfunctions.ts @@ -1,5 +1,4 @@ -import { InputTransformation, Pipe } from '@aws-cdk/aws-pipes-alpha'; -import { SqsSource } from '@aws-cdk/aws-pipes-sources-alpha'; +import { InputTransformation, IPipe, ISource, Pipe, SourceConfig } from '@aws-cdk/aws-pipes-alpha'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import * as cdk from 'aws-cdk-lib'; import * as ssm from 'aws-cdk-lib/aws-ssm'; @@ -16,6 +15,26 @@ import { SfnStateMachine } from '../lib/stepfunctions'; const app = new cdk.App(); const stack = new cdk.Stack(app, 'aws-cdk-pipes-sfn-target'); const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue'); + +// When this module is promoted from alpha, TestSource should +// be replaced with SqsSource from @aws-cdk/aws-pipes-sources-alpha +class TestSource implements ISource { + sourceArn: string; + sourceParameters = undefined; + constructor(private readonly queue: cdk.aws_sqs.Queue) { + this.queue = queue; + this.sourceArn = queue.queueArn; + } + bind(_pipe: IPipe): SourceConfig { + return { + sourceParameters: this.sourceParameters, + }; + } + grantRead(pipeRole: cdk.aws_iam.IRole): void { + this.queue.grantConsumeMessages(pipeRole); + } +} + const parameterName = 'MyPipeParameter'; new ssm.StringParameter(stack, 'MyParameter', { parameterName, @@ -38,7 +57,7 @@ const targetStateMachine = new sfn.StateMachine(stack, 'TargetStateMachine', { }); new Pipe(stack, 'Pipe', { - source: new SqsSource(sourceQueue), + source: new TestSource(sourceQueue), target: new SfnStateMachine(targetStateMachine, { inputTransformation: InputTransformation.fromObject({ body: '<$.body>' }),