From fc5741b166360b9c70399339a390970fb088dd51 Mon Sep 17 00:00:00 2001 From: Adam Ruka Date: Sat, 6 Jul 2019 19:37:33 -0700 Subject: [PATCH] fix(codepipeline): rename crossRegionReplicationBuckets and hide crossRegionSupport. BREAKING CHANGE: crossRegionReplicationBuckets has been renamed to artifactBuckets. * Pipeline.crossRegionSupport has been removed. --- allowed-breaking-changes.txt | 3 ++ .../lib/cloudformation/pipeline-actions.ts | 2 +- .../test/test.pipeline.ts | 17 ++++++----- packages/@aws-cdk/aws-codepipeline/README.md | 2 +- .../@aws-cdk/aws-codepipeline/lib/action.ts | 2 +- .../@aws-cdk/aws-codepipeline/lib/pipeline.ts | 30 ++++++------------- 6 files changed, 24 insertions(+), 32 deletions(-) diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index e33478256fb7f..90c345a1945bc 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -10,3 +10,6 @@ removed:@aws-cdk/aws-elasticloadbalancingv2.ApplicationTargetGroup.metricIPv6Req removed:@aws-cdk/core.Fn.getAZs removed:@aws-cdk/aws-iam.UserProps.managedPolicyArns removed:@aws-cdk/aws-iam.GroupProps.managedPolicyArns +removed:@aws-cdk/aws-codepipeline.CrossRegionSupport +removed:@aws-cdk/aws-codepipeline.Pipeline.crossRegionSupport +removed:@aws-cdk/aws-codepipeline.PipelineProps.crossRegionReplicationBuckets diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts index 721a91f465963..c3ec78648de85 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts @@ -40,7 +40,7 @@ interface CloudFormationActionProps extends codepipeline.CommonAwsActionProps { /** * The AWS region the given Action resides in. * Note that a cross-region Pipeline requires replication buckets to function correctly. - * You can provide their names with the {@link PipelineProps#crossRegionReplicationBuckets} property. + * You can provide their names with the {@link PipelineProps#artifactBuckets} property. * If you don't, the CodePipeline Construct will create new Stacks in your CDK app containing those buckets, * that you will need to `cdk deploy` before deploying the main, Pipeline-containing Stack. * diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts index b7efe480d0de3..45232e338635e 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts @@ -568,7 +568,7 @@ export = { }, }); const pipeline = new codepipeline.Pipeline(stack, 'MyPipeline', { - crossRegionReplicationBuckets: { + artifactBuckets: { 'us-west-1': s3.Bucket.fromBucketName(stack, 'ImportedBucket', 'sfo-replication-bucket'), }, }); @@ -665,10 +665,11 @@ export = { ], })); - test.equal(pipeline.crossRegionSupport[pipelineRegion], undefined); - test.equal(pipeline.crossRegionSupport['us-west-1'], undefined); + const crossRegionSupport = (pipeline as any)._crossRegionSupport; + test.equal(crossRegionSupport[pipelineRegion], undefined); + test.equal(crossRegionSupport['us-west-1'], undefined); - const usEast1Support = pipeline.crossRegionSupport['us-east-1']; + const usEast1Support = crossRegionSupport['us-east-1']; test.notEqual(usEast1Support, undefined); test.equal(usEast1Support.stack.region, 'us-east-1'); test.equal(usEast1Support.stack.account, pipelineAccount); @@ -678,17 +679,17 @@ export = { test.done(); }, - 'allows specifying only one of artifactBucket and crossRegionReplicationBuckets'(test: Test) { + 'allows specifying only one of artifactBucket and artifactBuckets'(test: Test) { const stack = new Stack(); test.throws(() => { new codepipeline.Pipeline(stack, 'Pipeline', { artifactBucket: new s3.Bucket(stack, 'Bucket'), - crossRegionReplicationBuckets: { + artifactBuckets: { // even an empty map should trigger this validation... }, }); - }, /Only one of artifactBucket and crossRegionReplicationBuckets can be specified!/); + }, /Only one of artifactBucket and artifactBuckets can be specified!/); test.done(); }, @@ -702,7 +703,7 @@ export = { }); const sourceOutput = new codepipeline.Artifact(); new codepipeline.Pipeline(stack, 'Pipeline', { - crossRegionReplicationBuckets: { + artifactBuckets: { [pipelineRegion]: new s3.Bucket(stack, 'Bucket', { bucketName: 'my-pipeline-bucket', }) diff --git a/packages/@aws-cdk/aws-codepipeline/README.md b/packages/@aws-cdk/aws-codepipeline/README.md index 3cabab4b31265..d32b0677555af 100644 --- a/packages/@aws-cdk/aws-codepipeline/README.md +++ b/packages/@aws-cdk/aws-codepipeline/README.md @@ -95,7 +95,7 @@ It works like this: ```ts const pipeline = new codepipeline.Pipeline(this, 'MyFirstPipeline', { // ... - crossRegionReplicationBuckets: { + artifactBuckets: { // note that a physical name of the replication Bucket must be known at synthesis time 'us-west-1': s3.Bucket.fromBucketName(this, 'UsWest1ReplicationBucket', 'my-us-west-1-replication-bucket'), diff --git a/packages/@aws-cdk/aws-codepipeline/lib/action.ts b/packages/@aws-cdk/aws-codepipeline/lib/action.ts index 8ab5c79d88042..06c8c8d53e1f9 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/action.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/action.ts @@ -34,7 +34,7 @@ export interface ActionProperties { /** * The AWS region the given Action resides in. * Note that a cross-region Pipeline requires replication buckets to function correctly. - * You can provide their names with the {@link PipelineProps#crossRegionReplicationBuckets} property. + * You can provide their names with the {@link PipelineProps#artifactBuckets} property. * If you don't, the CodePipeline Construct will create new Stacks in your CDK app containing those buckets, * that you will need to `cdk deploy` before deploying the main, Pipeline-containing Stack. * diff --git a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts index cbc3e524f27de..48240d882f535 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts @@ -89,7 +89,7 @@ export interface PipelineProps { * * @default - None. */ - readonly crossRegionReplicationBuckets?: { [region: string]: s3.IBucket }; + readonly artifactBuckets?: { [region: string]: s3.IBucket }; /** * The list of Stages, in order, @@ -199,9 +199,9 @@ export class Pipeline extends PipelineBase { validateName('Pipeline', this.physicalName); - // only one of artifactBucket and crossRegionReplicationBuckets can be supplied - if (props.artifactBucket && props.crossRegionReplicationBuckets) { - throw new Error('Only one of artifactBucket and crossRegionReplicationBuckets can be specified!'); + // only one of artifactBucket and artifactBuckets can be supplied + if (props.artifactBucket && props.artifactBuckets) { + throw new Error('Only one of artifactBucket and artifactBuckets can be specified!'); } // If a bucket has been provided, use it - otherwise, create a bucket. @@ -237,8 +237,8 @@ export class Pipeline extends PipelineBase { this.artifactBucket.grantReadWrite(this.role); this.pipelineName = this.getResourceNameAttribute(codePipeline.ref); this.pipelineVersion = codePipeline.attrVersion; - this.crossRegionReplicationBuckets = props.crossRegionReplicationBuckets || {}; - this.crossRegionBucketsPassed = !!props.crossRegionReplicationBuckets; + this.crossRegionReplicationBuckets = props.artifactBuckets || {}; + this.crossRegionBucketsPassed = !!props.artifactBuckets; this.artifactStores = {}; // Does not expose a Fn::GetAtt for the ARN so we'll have to make it ourselves @@ -289,18 +289,6 @@ export class Pipeline extends PipelineBase { return this.stages.length; } - /** - * Returns all of the {@link CrossRegionSupportStack}s that were generated automatically - * when dealing with Actions that reside in a different region than the Pipeline itself. - */ - public get crossRegionSupport(): { [region: string]: CrossRegionSupport } { - const ret: { [region: string]: CrossRegionSupport } = {}; - Object.keys(this._crossRegionSupport).forEach((key) => { - ret[key] = this._crossRegionSupport[key]; - }); - return ret; - } - /** @internal */ public _attachActionToPipeline(stage: Stage, action: IAction, actionScope: Construct): FullActionDescriptor { // handle cross-region actions here @@ -451,9 +439,9 @@ export class Pipeline extends PipelineBase { if (props.artifactBucket) { return props.artifactBucket; } - if (props.crossRegionReplicationBuckets) { + if (props.artifactBuckets) { const pipelineRegion = this.requireRegion(); - return props.crossRegionReplicationBuckets[pipelineRegion]; + return props.artifactBuckets[pipelineRegion]; } return undefined; } @@ -618,7 +606,7 @@ export class Pipeline extends PipelineBase { * the cross-region capabilities of CodePipeline. * You get instances of this interface from the {@link Pipeline#crossRegionSupport} property. */ -export interface CrossRegionSupport { +interface CrossRegionSupport { /** * The Stack that has been created to house the replication Bucket * required for this region.