Skip to content

Commit

Permalink
fix(codepipeline): rename crossRegionReplicationBuckets and hide cros…
Browse files Browse the repository at this point in the history
…sRegionSupport.

BREAKING CHANGE: crossRegionReplicationBuckets has been renamed to artifactBuckets.
* Pipeline.crossRegionSupport has been removed.
  • Loading branch information
skinny85 committed Jul 7, 2019
1 parent ec1c5b7 commit fc5741b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 32 deletions.
3 changes: 3 additions & 0 deletions allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
17 changes: 9 additions & 8 deletions packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
},
});
Expand Down Expand Up @@ -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);
Expand All @@ -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();
},

Expand All @@ -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',
})
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline/lib/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
30 changes: 9 additions & 21 deletions packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit fc5741b

Please sign in to comment.