diff --git a/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts b/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts index aac53864eb983..1b96fa146ec4c 100644 --- a/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts +++ b/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts @@ -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), diff --git a/packages/@aws-cdk/cli-lib-alpha/lib/commands/bootstrap.ts b/packages/@aws-cdk/cli-lib-alpha/lib/commands/bootstrap.ts index 1dffabfdfb945..64f61613994bc 100644 --- a/packages/@aws-cdk/cli-lib-alpha/lib/commands/bootstrap.ts +++ b/packages/@aws-cdk/cli-lib-alpha/lib/commands/bootstrap.ts @@ -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:///` + * + * @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 diff --git a/packages/@aws-cdk/cli-lib-alpha/test/commands.test.ts b/packages/@aws-cdk/cli-lib-alpha/test/commands.test.ts index 710bc278b2ff4..acc6c5736ecde 100644 --- a/packages/@aws-cdk/cli-lib-alpha/test/commands.test.ts +++ b/packages/@aws-cdk/cli-lib-alpha/test/commands.test.ts @@ -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(), + ); + }); });