Skip to content

Commit 44134ad

Browse files
authored
fix(cli): bootstrap respects qualifier from cdk.json (#31410)
closes #28249. The qualifier property can be set via the context key "@aws-cdk/core:bootstrapQualifier" and if omitted, the arbitrary default is `hnb659fds`. In the case of `cdk bootstrap`, there is an additional way to set the qualifier via the `--qualifier` CLI option. Specific to the `cdk bootstrap` logic, we currently only honor the command line argument, which is an error. Ultimately, the following `cdk bootstrap` calls should be identical: - `cdk bootstrap` with the following `cdk.json` file: ```json { "@aws-cdk/core:bootstrapQualifier": "abcde", } ``` - `cdk bootstrap --qualifier="abcde"` I've made the decision that the `--qualifier` parameter takes precedent over the `cdk.json` context if they are both set.
1 parent 1726abd commit 44134ad

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

packages/aws-cdk/lib/api/bootstrap/bootstrap-props.ts

-1
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,4 @@ export interface BootstrappingParameters {
129129
* @default - No value, optional argument
130130
*/
131131
readonly customPermissionsBoundary?: string;
132-
133132
}

packages/aws-cdk/lib/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
547547
bucketName: configuration.settings.get(['toolkitBucket', 'bucketName']),
548548
kmsKeyId: configuration.settings.get(['toolkitBucket', 'kmsKeyId']),
549549
createCustomerMasterKey: args.bootstrapCustomerKey,
550-
qualifier: args.qualifier,
550+
qualifier: args.qualifier ?? configuration.context.get('@aws-cdk/core:bootstrapQualifier'),
551551
publicAccessBlockConfiguration: args.publicAccessBlockConfiguration,
552552
examplePermissionsBoundary: argv.examplePermissionsBoundary,
553553
customPermissionsBoundary: argv.customPermissionsBoundary,

packages/aws-cdk/test/cdk-toolkit.test.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { HotswapMode } from '../lib/api/hotswap/common';
6969
import { Template } from '../lib/api/util/cloudformation';
7070
import { CdkToolkit, Tag } from '../lib/cdk-toolkit';
7171
import { RequireApproval } from '../lib/diff';
72+
import { Configuration } from '../lib/settings';
7273
import { flatten } from '../lib/util';
7374

7475
let cloudExecutable: MockCloudExecutable;
@@ -115,7 +116,6 @@ describe('readCurrentTemplate', () => {
115116
let mockForEnvironment = jest.fn();
116117
let mockCloudExecutable: MockCloudExecutable;
117118
beforeEach(() => {
118-
119119
template = {
120120
Resources: {
121121
Func: {
@@ -394,6 +394,29 @@ describe('readCurrentTemplate', () => {
394394
});
395395
});
396396

397+
describe('bootstrap', () => {
398+
test('accepts qualifier from context', async () => {
399+
// GIVEN
400+
const toolkit = defaultToolkitSetup();
401+
const configuration = new Configuration();
402+
configuration.context.set('@aws-cdk/core:bootstrapQualifier', 'abcde');
403+
404+
// WHEN
405+
await toolkit.bootstrap(['aws://56789/south-pole'], bootstrapper, {
406+
parameters: {
407+
qualifier: configuration.context.get('@aws-cdk/core:bootstrapQualifier'),
408+
},
409+
});
410+
411+
// THEN
412+
expect(bootstrapper.bootstrapEnvironment).toHaveBeenCalledWith(expect.anything(), expect.anything(), {
413+
parameters: {
414+
qualifier: 'abcde',
415+
},
416+
});
417+
});
418+
});
419+
397420
describe('deploy', () => {
398421
test('fails when no valid stack names are given', async () => {
399422
// GIVEN

0 commit comments

Comments
 (0)