Skip to content
forked from aws/aws-cdk

Commit

Permalink
Merge pull request #69 from jose-clickup/add-CRR-buckets-integ-test
Browse files Browse the repository at this point in the history
added crr buckets integ test
  • Loading branch information
ahammond authored Jan 2, 2024
2 parents 7e797bf + 377a595 commit 74b5a26
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// eslint-disable-next-line import/no-extraneous-dependencies
/// !cdk-integ PipelineStack pragma:set-context:@aws-cdk/core:newStyleStackSynthesis=true
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { App, Stack, StackProps, Stage, StageProps, RemovalPolicy } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as integ from '@aws-cdk/integ-tests-alpha';
import * as pipelines from 'aws-cdk-lib/pipelines';
import * as s3 from 'aws-cdk-lib/aws-s3';

const regions = ['us-east-1', 'us-west-2'];

class PipelineStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

const regionalBucket = new s3.Bucket(this, 'RegionalBucket', {
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
encryption: s3.BucketEncryption.S3_MANAGED,
enforceSSL: true,
versioned: true,
removalPolicy: RemovalPolicy.DESTROY,
});

const crossRegionReplicationBuckets = {
'us-east-1': regionalBucket,
};

const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
synth: new pipelines.ShellStep('Synth', {
input: pipelines.CodePipelineSource.gitHub('jose-clickup/cdk-pipelines-demo', 'main'),
// commands: ['npm ci', 'npm run build', 'npx cdk synth'],
commands: ['echo Running integ tests...'],
}),
// Error: Only one of artifactBucket and crossRegionReplicationBuckets can be specified!
// artifactBucket,
crossRegionReplicationBuckets,
});

const wave = pipeline.addWave('MultiRegion');
for (const region of regions) {
wave.addStage(new AppStage(this, region, { env: { region: region } }));
}
}
}

class AppStage extends Stage {
constructor(scope: Construct, id: string, props?: StageProps) {
super(scope, id, props);

const stack1 = new Stack(this, 'Queue1');
new sqs.Queue(stack1, 'Queue');

const stack2 = new Stack(this, 'Queue2');
new sqs.Queue(stack2, 'OtherQueue');
}
}

const app = new App({
context: {
'@aws-cdk/core:newStyleStackSynthesis': '1',
},
});

const stack = new PipelineStack(app, 'PipelineStack', {
env: {
region: 'us-east-1',
//Error("You need to specify an explicit account when using CodePipeline's cross-region support")
account: '425845004253',
},
});

new integ.IntegTest(
app,
'cdk-integ-codepipeline-with-cross-region-replication-buckets',
{
testCases: [stack],
},
);

app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,11 @@ export interface CodePipelineProps {
* @default - A new S3 bucket will be created.
*/
readonly artifactBucket?: s3.IBucket;

/**
* A map of region to S3 bucket name used for cross-region CodePipeline.
* For every Action that you specify targeting a different region than the Pipeline itself,
* if you don't provide an explicit Bucket for that region using this property,
* the construct will automatically create a Stack containing an S3 Bucket in that region.
*
* Passed directly through to the {@link cp.Pipeline}.
*
* @default - no cross region replication buckets.
Expand Down

0 comments on commit 74b5a26

Please sign in to comment.