Skip to content

Commit ac40aed

Browse files
authored
feat(cli-lib): add missing deploy options (#25042)
Add missing deploy options to the cdk cli lib. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d8267b7 commit ac40aed

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

packages/@aws-cdk/cli-lib-alpha/lib/cli.ts

+11
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ export class AwsCdkCli implements IAwsCdkCli {
175175
...renderBooleanArg('previous-parameters', options.usePreviousParameters),
176176
...renderBooleanArg('rollback', options.rollback),
177177
...renderBooleanArg('staging', options.staging),
178+
...renderBooleanArg('asset-parallelism', options.assetParallelism),
179+
...renderBooleanArg('asset-prebuild', options.assetPrebuild),
180+
...renderNumberArg('concurrency', options.concurrency),
178181
...options.reuseAssets ? renderArrayArg('--reuse-assets', options.reuseAssets) : [],
179182
...options.notificationArns ? renderArrayArg('--notification-arns', options.notificationArns) : [],
180183
...options.parameters ? renderMapArrayArg('--parameters', options.parameters) : [],
@@ -257,6 +260,14 @@ function renderBooleanArg(arg: string, value?: boolean): string[] {
257260
}
258261
}
259262

263+
function renderNumberArg(arg: string, value?: number): string[] {
264+
if (typeof value === 'undefined') {
265+
return [];
266+
}
267+
268+
return [`--${arg}`, value.toString(10)];
269+
}
270+
260271
/**
261272
* Run code from a different working directory
262273
*/

packages/@aws-cdk/cli-lib-alpha/lib/commands/deploy.ts

+21
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ export interface DeployOptions extends SharedOptions {
105105
* @default StackActivityProgress.EVENTS
106106
*/
107107
readonly progress?: StackActivityProgress;
108+
109+
/**
110+
* Maximum number of simultaneous deployments (dependency permitting) to execute.
111+
*
112+
* @default 1
113+
*/
114+
readonly concurrency?: number;
115+
116+
/**
117+
* Whether to build/publish assets in parallel.
118+
*
119+
* @default false
120+
*/
121+
readonly assetParallelism?: boolean;
122+
123+
/**
124+
* Whether to build all assets before deploying the first stack (useful for failing Docker builds)
125+
*
126+
* @default true
127+
*/
128+
readonly assetPrebuild?: boolean;
108129
}
109130

110131
/**

packages/@aws-cdk/cli-lib-alpha/test/commands.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ describe('deploy', () => {
7070
versionReporting: true,
7171
usePreviousParameters: true,
7272
progress: StackActivityProgress.BAR,
73+
concurrency: 5,
74+
assetParallelism: true,
75+
assetPrebuild: true,
7376
});
7477

7578
// THEN
@@ -83,6 +86,9 @@ describe('deploy', () => {
8386
'--previous-parameters',
8487
'--no-rollback',
8588
'--no-staging',
89+
'--asset-parallelism',
90+
'--asset-prebuild',
91+
'--concurrency', '5',
8692
'--reuse-assets', 'asset1234',
8793
'--reuse-assets', 'asset5678',
8894
'--outputs-file', 'outputs.json',
@@ -204,6 +210,25 @@ describe('deploy', () => {
204210
expect.anything(),
205211
);
206212
});
213+
214+
test('can parse number arguments', async () => {
215+
// WHEN
216+
await cdk.deploy({
217+
stacks: ['Stack1'],
218+
concurrency: 5,
219+
});
220+
221+
// THEN
222+
expect(jest.mocked(cli.exec)).toHaveBeenCalledWith(
223+
[
224+
'deploy',
225+
'--concurrency', '5',
226+
'--progress', 'events',
227+
'Stack1',
228+
],
229+
expect.anything(),
230+
);
231+
});
207232
});
208233

209234
describe('synth', () => {

0 commit comments

Comments
 (0)