Skip to content

Commit

Permalink
fix(codepipeline): allow providing Tokens as the physical name of the…
Browse files Browse the repository at this point in the history
… Pipeline. (#1800)

Fixes #1788
  • Loading branch information
skinny85 authored and rix0rrr committed Feb 20, 2019
1 parent 5dec01a commit f6aea1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-codepipeline-api/lib/validation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cdk = require('@aws-cdk/cdk');
import { ActionCategory } from "./action";
import { Artifact } from "./artifact";

Expand Down Expand Up @@ -44,6 +45,11 @@ const VALID_IDENTIFIER_REGEX = /^[a-zA-Z0-9.@_-]{1,100}$/;
* This can be used to validate the name of all components of a pipeline.
*/
export function validateName(thing: string, name: string | undefined) {
// name could be a Token - in that case, skip validation altogether
if (cdk.unresolved(name)) {
return;
}

if (name !== undefined && !VALID_IDENTIFIER_REGEX.test(name)) {
throw new Error(`${thing} name must match regular expression: ${VALID_IDENTIFIER_REGEX.toString()}, got '${name}'`);
}
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-codepipeline/test/test.pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ export = {
test.done();
},

'Tokens can be used as physical names of the Pipeline'(test: Test) {
const stack = new cdk.Stack(undefined, 'StackName');

new codepipeline.Pipeline(stack, 'Pipeline', {
pipelineName: stack.stackName,
});

expect(stack, true).to(haveResourceLike('AWS::CodePipeline::Pipeline', {
"Name": {
"Ref": "AWS::StackName",
},
}));

test.done();
},

'github action uses ThirdParty owner'(test: Test) {
const stack = new cdk.Stack();

Expand Down

0 comments on commit f6aea1b

Please sign in to comment.