Skip to content

Commit b5ff4d6

Browse files
authored
fix(codepipeline): cross-region support stack requires bootstrapping (#10217)
The cross-region support stack was intended to not require bootstrapping. The recent "version check" feature added to the default synthesizer did lead to bootstrapping being required (because an SSM parameter needed to be provisioned in the target environment). Make adding that check switchable and switch it off for the support stack (which uses a `BootstraplessSynthesizer`). Fixes #10215. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8791f88 commit b5ff4d6

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

packages/@aws-cdk/core/lib/stack-synthesizers/bootstrapless-synthesizer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class BootstraplessSynthesizer extends DefaultStackSynthesizer {
3535
super({
3636
deployRoleArn: props.deployRoleArn,
3737
cloudFormationExecutionRole: props.cloudFormationExecutionRoleArn,
38+
generateBootstrapVersionRule: false,
3839
});
3940
}
4041

packages/@aws-cdk/core/lib/stack-synthesizers/default-synthesizer.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ export interface DefaultStackSynthesizerProps {
140140
* @default - Value of context key '@aws-cdk/core:bootstrapQualifier' if set, otherwise `DefaultStackSynthesizer.DEFAULT_QUALIFIER`
141141
*/
142142
readonly qualifier?: string;
143+
144+
/**
145+
* Whether to add a Rule to the stack template verifying the bootstrap stack version
146+
*
147+
* This generally should be left set to `true`, unless you explicitly
148+
* want to be able to deploy to an unbootstrapped environment.
149+
*
150+
* @default true
151+
*/
152+
readonly generateBootstrapVersionRule?: boolean;
143153
}
144154

145155
/**
@@ -235,7 +245,9 @@ export class DefaultStackSynthesizer implements IStackSynthesizer {
235245
this.imageAssetPublishingRoleArn = specialize(this.props.imageAssetPublishingRoleArn ?? DefaultStackSynthesizer.DEFAULT_IMAGE_ASSET_PUBLISHING_ROLE_ARN);
236246
/* eslint-enable max-len */
237247

238-
addBootstrapVersionRule(stack, MIN_BOOTSTRAP_STACK_VERSION, qualifier);
248+
if (this.props.generateBootstrapVersionRule ?? true) {
249+
addBootstrapVersionRule(stack, MIN_BOOTSTRAP_STACK_VERSION, qualifier);
250+
}
239251
}
240252

241253
public addFileAsset(asset: FileAssetSource): FileAssetLocation {

packages/@aws-cdk/core/test/stack-synthesis/test.new-style-synthesis.ts

+18
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ export = {
8383
test.done();
8484
},
8585

86+
'version check is not added to template if disabled'(test: Test) {
87+
// GIVEN
88+
stack = new Stack(app, 'Stack2', {
89+
synthesizer: new DefaultStackSynthesizer({
90+
generateBootstrapVersionRule: false,
91+
}),
92+
});
93+
new CfnResource(stack, 'Resource', {
94+
type: 'Some::Resource',
95+
});
96+
97+
// THEN
98+
const template = app.synth().getStackByName('Stack2').template;
99+
test.equal(template?.Rules?.CheckBootstrapVersion, undefined);
100+
101+
test.done();
102+
},
103+
86104
'add file asset'(test: Test) {
87105
// WHEN
88106
const location = stack.synthesizer.addFileAsset({

0 commit comments

Comments
 (0)