Skip to content
forked from aws/aws-cdk
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

added crr buckets integ test #69

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
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
Loading