Skip to content

Commit

Permalink
fix(pipe): Fix pipe name returns wrong value
Browse files Browse the repository at this point in the history
closes: Pipe "pipeName" property do not match with "PipeName" metrics dimension #16
  • Loading branch information
RaphaelManke committed Jun 8, 2023
1 parent b88c735 commit 863e66e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions e2e/sources/Sqs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, RemovalPolicy, Stack } from 'aws-cdk-lib';
import { App, CfnOutput, RemovalPolicy, Stack } from 'aws-cdk-lib';
import { LogGroup } from 'aws-cdk-lib/aws-logs';
import { Queue } from 'aws-cdk-lib/aws-sqs';
import { LogsTarget, Pipe, SqsSource } from '../../src';
Expand All @@ -14,7 +14,12 @@ const targetLogGroup = new LogGroup(stack, 'TargetLogGroup', {
const target = new LogsTarget(targetLogGroup, {
logStreamName: 'test',
});
new Pipe(stack, 'Pipe', {
const pipe = new Pipe(stack, 'Pipe', {
source,
target,
});
// const pipeName = (pipe.node.defaultChild as CfnPipe).ref;
new CfnOutput(stack, 'PipeName', {
value: pipe.pipeName,
});

8 changes: 4 additions & 4 deletions src/Pipe.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
IResource,
Lazy,
Names,
Resource,
} from 'aws-cdk-lib';
import { IRole, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
Expand Down Expand Up @@ -110,15 +108,14 @@ export class Pipe extends PipeBase {

constructor(scope: Construct, id: string, props: IPipeProps) {
const pipeName =
props.name || Lazy.string({ produce: () => Names.uniqueId(this) });
props.name;
super(scope, id, { physicalName: pipeName });

this.pipeRole =
props.role ||
new Role(this, 'Role', {
assumedBy: new ServicePrincipal('pipes.amazonaws.com'),
});
this.pipeName = pipeName;

const sourceParameters = {
...props.source.sourceParameters,
Expand All @@ -143,6 +140,9 @@ export class Pipe extends PipeBase {
enrichmentParameters: props.enrichment?.enrichmentParameters,
tags: props.tags,
});

this.pipeName = resource.ref;
this.pipeArn = resource.attrArn;

}
}

0 comments on commit 863e66e

Please sign in to comment.