Skip to content
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

fix(cli-lib): cannot bootstrap specific environment #31713

Merged
merged 1 commit into from
Oct 10, 2024
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
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(),
);
});
});