Skip to content

Commit

Permalink
fix(cli-lib): cannot bootstrap specific environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Oct 10, 2024
1 parent d80e3cd commit 5f4c7b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ export class AwsCdkCli implements IAwsCdkCli {
* cdk bootstrap
*/
public async bootstrap(options: BootstrapOptions = {}) {
const envs = options.environments ?? [];
const bootstrapCommandArgs: string[] = [
...envs,
...renderBooleanArg('force', options.force),
...renderBooleanArg('show-template', options.showTemplate),
...renderBooleanArg('terminationProtection', options.terminationProtection),
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/lib/commands/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { SharedOptions } from './common';
* Options to use with cdk bootstrap
*/
export interface BootstrapOptions extends SharedOptions {
/**
* The target AWS environments to deploy the bootstrap stack to.
* Uses the following format: `aws://<account-id>/<region>`
*
* @example "aws://123456789012/us-east-1"
* @default - Bootstrap all environments referenced in the CDK app or determine an environment from local configuration.
*/
readonly environments?: string[];

/**
* The name of the CDK toolkit stack to create
Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,16 @@ describe('list', () => {
);
});

test('bootstrap specific environment', async () => {
// WHEN
await cdk.bootstrap({
environments: ['aws://123456789012/us-east-1']
});

// THEN
expect(jest.mocked(cli.exec)).toHaveBeenCalledWith(
['bootstrap', 'aws://123456789012/us-east-1', '--all'],
expect.anything(),
);
});
});

0 comments on commit 5f4c7b6

Please sign in to comment.