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 marked as experimental.
  • Loading branch information
skinny85 committed Jul 7, 2019
1 parent d6f5207 commit 2ab080f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ 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.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
10 changes: 5 additions & 5 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 @@ -678,17 +678,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 +702,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
20 changes: 12 additions & 8 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 @@ -292,6 +292,8 @@ export class Pipeline extends PipelineBase {
/**
* 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.
*
* @experimental
*/
public get crossRegionSupport(): { [region: string]: CrossRegionSupport } {
const ret: { [region: string]: CrossRegionSupport } = {};
Expand Down Expand Up @@ -451,9 +453,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 @@ -617,6 +619,8 @@ export class Pipeline extends PipelineBase {
* An interface representing resources generated in order to support
* the cross-region capabilities of CodePipeline.
* You get instances of this interface from the {@link Pipeline#crossRegionSupport} property.
*
* @experimental
*/
export interface CrossRegionSupport {
/**
Expand Down

0 comments on commit 2ab080f

Please sign in to comment.