Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(codepipeline): allow providing Tokens as the physical name of the Pipeline #1800

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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