Skip to content

Commit dab83cc

Browse files
authored
feat(cdk-cli-wrapper): add progress argument for cdk deploy (#21762)
Adding the ability to specify `--progress` when using cdk `deploy`. I'm setting the default to `events` as opposed to the default of `bar` in the CLI. Since this library is currently only used in the integ-runner, and if published will most likely be used in automation I think it makes more sense to set progress to `events`. This is really useful when running multiple integration tests in parallel. If set to `bar` (CLI default) the logs will overlap/overwrite each other which makes it difficult to troubleshoot. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d942324 commit dab83cc

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

packages/cdk-cli-wrapper/lib/cdk-wrapper.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DefaultCdkOptions, DeployOptions, DestroyOptions, SynthOptions, ListOptions } from './commands';
1+
import { DefaultCdkOptions, DeployOptions, DestroyOptions, SynthOptions, ListOptions, StackActivityProgress } from './commands';
22
import { exec } from './utils';
33

44
/**
@@ -161,6 +161,7 @@ export class CdkCliWrapper implements ICdk {
161161
...options.requireApproval ? ['--require-approval', options.requireApproval] : [],
162162
...options.changeSetName ? ['--change-set-name', options.changeSetName] : [],
163163
...options.toolkitStackName ? ['--toolkit-stack-name', options.toolkitStackName] : [],
164+
...options.progress ? ['--progress', options.progress] : ['--progress', StackActivityProgress.EVENTS],
164165
...this.createDefaultArguments(options),
165166
];
166167

packages/cdk-cli-wrapper/lib/commands/deploy.ts

+26
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,30 @@ export interface DeployOptions extends DefaultCdkOptions {
9494
* @default false
9595
*/
9696
readonly ci?: boolean;
97+
98+
/**
99+
* Display mode for stack activity events
100+
*
101+
* The default in the CLI is StackActivityProgress.BAR, but
102+
* since the cli-wrapper will most likely be run in automation it makes
103+
* more sense to set the default to StackActivityProgress.EVENTS
104+
*
105+
* @default StackActivityProgress.EVENTS
106+
*/
107+
readonly progress?: StackActivityProgress;
108+
}
109+
110+
/**
111+
* Supported display modes for stack deployment activity
112+
*/
113+
export enum StackActivityProgress {
114+
/**
115+
* Displays a progress bar with only the events for the resource currently being deployed
116+
*/
117+
BAR = 'bar',
118+
119+
/**
120+
* Displays complete history with all CloudFormation stack events
121+
*/
122+
EVENTS = 'events',
97123
}

packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as child_process from 'child_process';
22
import { CdkCliWrapper } from '../lib/cdk-wrapper';
3-
import { RequireApproval } from '../lib/commands';
3+
import { RequireApproval, StackActivityProgress } from '../lib/commands';
44
let spawnSyncMock: jest.SpyInstance;
55

66
beforeEach(() => {
@@ -33,7 +33,7 @@ test('default deploy', () => {
3333
// THEN
3434
expect(spawnSyncMock).toHaveBeenCalledWith(
3535
expect.stringMatching(/cdk/),
36-
['deploy', '--app', 'node bin/my-app.js', 'test-stack1'],
36+
['deploy', '--progress', 'events', '--app', 'node bin/my-app.js', 'test-stack1'],
3737
expect.objectContaining({
3838
env: expect.anything(),
3939
cwd: '/project',
@@ -82,6 +82,7 @@ test('deploy with all arguments', () => {
8282
toolkitStackName: 'Toolkit',
8383
versionReporting: true,
8484
usePreviousParameters: true,
85+
progress: StackActivityProgress.BAR,
8586
});
8687

8788
// THEN
@@ -120,6 +121,7 @@ test('deploy with all arguments', () => {
120121
'--change-set-name', 'my-change-set',
121122
'--toolkit-stack-name', 'Toolkit',
122123
'--previous-parameters',
124+
'--progress', 'bar',
123125
'--app',
124126
'node bin/my-app.js',
125127
'test-stack1',
@@ -149,6 +151,7 @@ test('can parse boolean arguments', () => {
149151
expect.stringMatching(/cdk/),
150152
[
151153
'deploy',
154+
'--progress', 'events',
152155
'--app',
153156
'node bin/my-app.js',
154157
'--json',
@@ -184,6 +187,7 @@ test('can parse parameters', () => {
184187
'deploy',
185188
'--parameters', 'myparam=test',
186189
'--parameters', 'test-stack1:myotherparam=test',
190+
'--progress', 'events',
187191
'--app',
188192
'node bin/my-app.js',
189193
'test-stack1',
@@ -214,6 +218,7 @@ test('can parse context', () => {
214218
expect.stringMatching(/cdk/),
215219
[
216220
'deploy',
221+
'--progress', 'events',
217222
'--app',
218223
'node bin/my-app.js',
219224
'--context', 'myContext=value',
@@ -248,6 +253,7 @@ test('can parse array arguments', () => {
248253
'deploy',
249254
'--notification-arns', 'arn:aws:us-east-1:1111111111:some:resource',
250255
'--notification-arns', 'arn:aws:us-east-1:1111111111:some:other-resource',
256+
'--progress', 'events',
251257
'--app',
252258
'node bin/my-app.js',
253259
'test-stack1',
@@ -275,7 +281,7 @@ test('can provide additional environment', () => {
275281
// THEN
276282
expect(spawnSyncMock).toHaveBeenCalledWith(
277283
expect.stringMatching(/cdk/),
278-
['deploy', '--app', 'node bin/my-app.js', 'test-stack1'],
284+
['deploy', '--progress', 'events', '--app', 'node bin/my-app.js', 'test-stack1'],
279285
expect.objectContaining({
280286
env: expect.objectContaining({
281287
KEY: 'value',

0 commit comments

Comments
 (0)