Skip to content

Commit

Permalink
Update int test
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Nov 2, 2024
1 parent a89b4f3 commit db15170
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
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';
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { ApiDestinationTarget } from '../lib/api-destination';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-pipes-targets-api-dest');
const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue');

/*
* This integration test creates an API Gateway HTTP API in order to
* validate that the pipe executes properly. The flow is as follows:
Expand All @@ -19,6 +14,29 @@ const sourceQueue = new cdk.aws_sqs.Queue(stack, 'SourceQueue');
* --> API Gateway HTTP API --> Lambda function
*/

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-pipes-targets-api-dest');
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 fn = new lambda.Function(stack, 'ConnectHandler', {
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'index.handler',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit db15170

Please sign in to comment.