forked from aws/aws-cdk-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-config.ts
More file actions
528 lines (526 loc) · 34.2 KB
/
cli-config.ts
File metadata and controls
528 lines (526 loc) · 34.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
import { RequireApproval } from '@aws-cdk/cloud-assembly-schema';
// eslint-disable-next-line import/no-extraneous-dependencies
import { CliHelpers, type CliConfig } from '@aws-cdk/user-input-gen';
import * as cdk_from_cfn from 'cdk-from-cfn';
import { StackActivityProgress } from '../commands/deploy';
import { availableInitLanguages } from '../commands/init';
import { JS_PACKAGE_MANAGERS } from '../commands/init/package-manager';
import { getLanguageAlias } from '../commands/language';
export const YARGS_HELPERS = new CliHelpers('./util/yargs-helpers');
/**
* Source of truth for all CDK CLI commands. `user-input-gen` translates this into:
*
* - the `yargs` definition in `lib/parse-command-line-arguments.ts`.
* - the `UserInput` type in `lib/user-input.ts`.
* - the `convertXxxToUserInput` functions in `lib/convert-to-user-input.ts`.
*/
export async function makeConfig(): Promise<CliConfig> {
return {
globalOptions: {
'app': { type: 'string', alias: 'a', desc: 'REQUIRED WHEN RUNNING APP: command-line for executing your app or a cloud assembly directory (e.g. "node bin/my-app.js"). Can also be specified in cdk.json or ~/.cdk.json', requiresArg: true },
'build': { type: 'string', desc: 'Command-line for a pre-synth build' },
'context': { type: 'array', alias: 'c', desc: 'Add contextual string parameter (KEY=VALUE)' },
'plugin': { type: 'array', alias: 'p', desc: 'Name or path of a node package that extend the CDK features. Can be specified multiple times' },
'trace': { type: 'boolean', desc: 'Print trace for stack warnings' },
'strict': { type: 'boolean', desc: 'Do not construct stacks with warnings' },
'lookups': { type: 'boolean', desc: 'Perform context lookups (synthesis fails if this is disabled and context lookups need to be performed)', default: true },
'ignore-errors': { type: 'boolean', default: false, desc: 'Ignores synthesis errors, which will likely produce an invalid output' },
'json': { type: 'boolean', alias: 'j', desc: 'Use JSON output instead of YAML when templates are printed to STDOUT', default: false },
'verbose': { type: 'boolean', alias: 'v', desc: 'Show debug logs (specify multiple times to increase verbosity)', default: false, count: true },
'debug': { type: 'boolean', desc: 'Debug the CDK app. Log additional information during synthesis, such as creation stack traces of tokens (sets CDK_DEBUG, will slow down synthesis)', default: false },
'profile': { type: 'string', desc: 'Use the indicated AWS profile as the default environment', requiresArg: true },
'proxy': { type: 'string', desc: 'Use the indicated proxy. Will read from HTTPS_PROXY environment variable if not specified', requiresArg: true },
'ca-bundle-path': { type: 'string', desc: 'Path to CA certificate to use when validating HTTPS requests. Will read from AWS_CA_BUNDLE environment variable if not specified', requiresArg: true },
'ec2creds': { type: 'boolean', alias: 'i', default: undefined, desc: 'Force trying to fetch EC2 instance credentials. Default: guess EC2 instance status' },
'version-reporting': { type: 'boolean', desc: 'Disable CLI telemetry and do not include the "AWS::CDK::Metadata" resource in synthesized templates (enabled by default)', default: undefined, alias: 'telemetry' },
'path-metadata': { type: 'boolean', desc: 'Include "aws:cdk:path" CloudFormation metadata for each resource (enabled by default)', default: undefined },
'asset-metadata': { type: 'boolean', desc: 'Include "aws:asset:*" CloudFormation metadata for resources that uses assets (enabled by default)', default: undefined },
'role-arn': { type: 'string', alias: 'r', desc: 'ARN of Role to use when invoking CloudFormation', default: undefined, requiresArg: true },
'staging': { type: 'boolean', desc: 'Copy assets to the output directory (use --no-staging to disable the copy of assets which allows local debugging via the SAM CLI to reference the original source files)', default: true },
'output': { type: 'string', alias: 'o', desc: 'Emits the synthesized cloud assembly into a directory (default: cdk.out)', requiresArg: true },
'notices': { type: 'boolean', desc: 'Show relevant notices' },
'no-color': { type: 'boolean', desc: 'Removes colors and other style from console output', default: false },
'ci': { type: 'boolean', desc: 'Force CI detection. If CI=true then logs will be sent to stdout instead of stderr', default: YARGS_HELPERS.isCI() },
'unstable': { type: 'array', desc: 'Opt in to unstable features. The flag indicates that the scope and API of a feature might still change. Otherwise the feature is generally production ready and fully supported. Can be specified multiple times.', default: [] },
'telemetry-file': { type: 'string', desc: 'Send telemetry data to a local file.', default: undefined },
'yes': { type: 'boolean', alias: 'y', desc: 'Automatically answer interactive prompts with the recommended response. This includes confirming actions.', default: false },
},
commands: {
'list': {
arg: {
name: 'STACKS',
variadic: true,
},
aliases: ['ls'],
description: 'Lists all stacks in the app',
options: {
'long': { type: 'boolean', default: false, alias: 'l', desc: 'Display environment information for each stack' },
'show-dependencies': { type: 'boolean', default: false, alias: 'd', desc: 'Display stack dependency information for each stack' },
},
},
'synth': {
arg: {
name: 'STACKS',
variadic: true,
},
aliases: ['synthesize'],
description: 'Synthesizes and prints the CloudFormation template for this stack',
options: {
exclusively: { type: 'boolean', alias: 'e', desc: 'Only synthesize requested stacks, don\'t include dependencies' },
validation: { type: 'boolean', desc: 'After synthesis, validate stacks with the "validateOnSynth" attribute set (can also be controlled with CDK_VALIDATION)', default: true },
quiet: { type: 'boolean', alias: 'q', desc: 'Do not output CloudFormation Template to stdout', default: false },
},
},
'bootstrap': {
arg: {
name: 'ENVIRONMENTS',
variadic: true,
},
description: 'Deploys the CDK toolkit stack into an AWS environment',
options: {
'bootstrap-bucket-name': { type: 'string', alias: ['b', 'toolkit-bucket-name'], desc: 'The name of the CDK toolkit bucket; bucket will be created and must not exist', default: undefined },
'bootstrap-kms-key-id': { type: 'string', desc: 'AWS KMS master key ID used for the SSE-KMS encryption (specify AWS_MANAGED_KEY to use an AWS-managed key)', default: undefined, conflicts: 'bootstrap-customer-key' },
'example-permissions-boundary': { type: 'boolean', alias: 'epb', desc: 'Use the example permissions boundary.', default: undefined, conflicts: 'custom-permissions-boundary' },
'custom-permissions-boundary': { type: 'string', alias: 'cpb', desc: 'Use the permissions boundary specified by name.', default: undefined, conflicts: 'example-permissions-boundary' },
'bootstrap-customer-key': { type: 'boolean', desc: 'Create a Customer Master Key (CMK) for the bootstrap bucket (you will be charged but can customize permissions, modern bootstrapping only)', default: undefined, conflicts: 'bootstrap-kms-key-id' },
'qualifier': { type: 'string', desc: 'String which must be unique for each bootstrap stack. You must configure it on your CDK app if you change this from the default.', default: undefined },
'public-access-block-configuration': { type: 'boolean', desc: 'Block public access configuration on CDK toolkit bucket (enabled by default) ', default: undefined },
'deny-external-id': { type: 'boolean', desc: 'Block AssumeRole access to all boostrapped roles if an ExternalId is provided (enabled by default) ', default: undefined },
'tags': { type: 'array', alias: 't', desc: 'Tags to add for the stack (KEY=VALUE)', default: [] },
'execute': { type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true },
'trust': { type: 'array', desc: 'The AWS account IDs that should be trusted to perform deployments into this environment (may be repeated, modern bootstrapping only)', default: [] },
'trust-for-lookup': { type: 'array', desc: 'The AWS account IDs that should be trusted to look up values in this environment (may be repeated, modern bootstrapping only)', default: [] },
'untrust': { type: 'array', desc: 'The AWS account IDs that should not be trusted by this environment (may be repeated, modern bootstrapping only)', default: [] },
'cloudformation-execution-policies': { type: 'array', desc: 'The Managed Policy ARNs that should be attached to the role performing deployments into this environment (may be repeated, modern bootstrapping only)', default: [] },
'force': { alias: 'f', type: 'boolean', desc: 'Always bootstrap even if it would downgrade template version', default: false },
'termination-protection': { type: 'boolean', default: undefined, desc: 'Toggle CloudFormation termination protection on the bootstrap stacks' },
'show-template': { type: 'boolean', desc: 'Instead of actual bootstrapping, print the current CLI\'s bootstrapping template to stdout for customization', default: false },
'toolkit-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack to create', requiresArg: true },
'template': { type: 'string', requiresArg: true, desc: 'Use the template from the given file instead of the built-in one (use --show-template to obtain an example)' },
'previous-parameters': { type: 'boolean', default: true, desc: 'Use previous values for existing parameters (you must specify all parameters on every deployment if this is disabled)' },
},
},
'gc': {
description: 'Garbage collect assets. Options detailed here: https://github.com/aws/aws-cdk-cli/tree/main/packages/aws-cdk#cdk-gc',
arg: {
name: 'ENVIRONMENTS',
variadic: true,
},
options: {
'action': { type: 'string', desc: 'The action (or sub-action) you want to perform. Valid entires are "print", "tag", "delete-tagged", "full".', default: 'full' },
'type': { type: 'string', desc: 'Specify either ecr, s3, or all', default: 'all' },
'rollback-buffer-days': { type: 'number', desc: 'Delete assets that have been marked as isolated for this many days', default: 0 },
'created-buffer-days': { type: 'number', desc: 'Never delete assets younger than this (in days)', default: 1 },
'confirm': { type: 'boolean', desc: 'Confirm via manual prompt before deletion', default: true },
'toolkit-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit"', requiresArg: true, conflicts: 'bootstrap-stack-name' },
'bootstrap-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit" (deprecated, use --toolkit-stack-name)', deprecated: 'use --toolkit-stack-name', requiresArg: true, conflicts: 'toolkit-stack-name' }, // TODO: remove when garbage collection is GA
},
},
'flags': {
description: 'View and toggle feature flags.',
arg: {
name: 'FLAGNAME',
variadic: true,
},
options: {
value: { type: 'string', desc: 'The value the user would like to set the feature flag configuration to', requiresArg: true },
set: { type: 'boolean', desc: 'Signifies the user would like to modify their feature flag configuration', requiresArg: false },
all: { type: 'boolean', desc: 'Modify or view all feature flags', requiresArg: false },
unconfigured: { type: 'boolean', desc: 'Modify unconfigured feature flags', requiresArg: false },
recommended: { type: 'boolean', desc: 'Change flags to recommended states', requiresArg: false },
default: { type: 'boolean', desc: 'Change flags to default state', requiresArg: false },
interactive: { type: 'boolean', alias: ['i'], desc: 'Interactive option for the flags command' },
safe: { type: 'boolean', desc: 'Enable all feature flags that do not impact the user\'s application', requiresArg: false },
concurrency: { type: 'number', alias: ['n'], desc: 'Maximum number of simultaneous synths to execute.', default: 4, requiresArg: true },
},
},
'deploy': {
description: 'Deploys the stack(s) named STACKS into your AWS account',
options: {
'all': { type: 'boolean', desc: 'Deploy all available stacks', default: false },
'build-exclude': { type: 'array', alias: 'E', desc: 'Do not rebuild asset with the given ID. Can be specified multiple times', default: [] },
'exclusively': { type: 'boolean', alias: 'e', desc: 'Only deploy requested stacks, don\'t include dependencies' },
'require-approval': { type: 'string', choices: [RequireApproval.NEVER, RequireApproval.ANYCHANGE, RequireApproval.BROADENING], desc: 'What security-sensitive changes need manual approval' },
'notification-arns': { type: 'array', desc: 'ARNs of SNS topics that CloudFormation will notify with stack related events. These will be added to ARNs specified with the \'notificationArns\' stack property.' },
// @deprecated(v2) -- tags are part of the Cloud Assembly and tags specified here will be overwritten on the next deployment
'tags': { type: 'array', alias: 't', desc: 'Tags to add to the stack (KEY=VALUE), overrides tags from Cloud Assembly (deprecated)' },
'execute': { type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet) (deprecated)', deprecated: true },
'change-set-name': { type: 'string', desc: 'Name of the CloudFormation change set to create (only if method is not direct)' },
'method': {
alias: 'm',
type: 'string',
choices: ['direct', 'change-set', 'prepare-change-set'],
requiresArg: true,
desc: 'How to perform the deployment. Direct is a bit faster but lacks progress information',
},
'import-existing-resources': { type: 'boolean', desc: 'Indicates if the stack set imports resources that already exist.', default: false },
'force': { alias: 'f', type: 'boolean', desc: 'Always deploy stack even if templates are identical', default: false },
'parameters': { type: 'array', desc: 'Additional parameters passed to CloudFormation at deploy time (STACK:KEY=VALUE)', default: {} },
'outputs-file': { type: 'string', alias: 'O', desc: 'Path to file where stack outputs will be written as JSON', requiresArg: true },
'previous-parameters': { type: 'boolean', default: true, desc: 'Use previous values for existing parameters (you must specify all parameters on every deployment if this is disabled)' },
'toolkit-stack-name': { type: 'string', desc: 'The name of the existing CDK toolkit stack (only used for app using legacy synthesis)', requiresArg: true },
'progress': { type: 'string', choices: [StackActivityProgress.BAR, StackActivityProgress.EVENTS], desc: 'Display mode for stack activity events' },
'rollback': {
type: 'boolean',
desc: "Rollback stack to stable state on failure. Defaults to 'true', iterate more rapidly with --no-rollback or -R. " +
'Note: do **not** disable this flag for deployments with resource replacements, as that will always fail',
negativeAlias: 'R',
},
'hotswap': {
type: 'boolean',
desc: "Attempts to perform a 'hotswap' deployment, " +
'but does not fall back to a full deployment if that is not possible. ' +
'Instead, changes to any non-hotswappable properties are ignored.' +
'Do not use this in production environments',
},
'hotswap-fallback': {
type: 'boolean',
desc: "Attempts to perform a 'hotswap' deployment, " +
'which skips CloudFormation and updates the resources directly, ' +
'and falls back to a full deployment if that is not possible. ' +
'Do not use this in production environments',
},
'hotswap-ecs-minimum-healthy-percent': {
type: 'number',
desc: 'Lower limit on the number of your service\'s tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount',
},
'hotswap-ecs-maximum-healthy-percent': {
type: 'number',
desc: 'Upper limit on the number of your service\'s tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount',
},
'hotswap-ecs-stabilization-timeout-seconds': {
type: 'number',
desc: 'Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount',
},
'watch': {
type: 'boolean',
desc: 'Continuously observe the project files, ' +
'and deploy the given stack(s) automatically when changes are detected. ' +
'Implies --hotswap by default',
},
'logs': {
type: 'boolean',
default: true,
desc: 'Show CloudWatch log events from all resources in the selected Stacks in the terminal. ' +
"'true' by default, use --no-logs to turn off. " +
"Only in effect if specified alongside the '--watch' option",
},
'concurrency': { type: 'number', desc: 'Maximum number of simultaneous deployments (dependency permitting) to execute.', default: 1, requiresArg: true },
'asset-parallelism': { type: 'boolean', desc: 'Whether to build/publish assets in parallel' },
'asset-prebuild': { type: 'boolean', desc: 'Whether to build all assets before deploying the first stack (useful for failing Docker builds)', default: true },
'ignore-no-stacks': { type: 'boolean', desc: 'Whether to deploy if the app contains no stacks', default: false },
},
arg: {
name: 'STACKS',
variadic: true,
},
},
'rollback': {
description: 'Rolls back the stack(s) named STACKS to their last stable state',
arg: {
name: 'STACKS',
variadic: true,
},
options: {
'all': { type: 'boolean', default: false, desc: 'Roll back all available stacks' },
'toolkit-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack the environment is bootstrapped with', requiresArg: true },
'force': {
alias: 'f',
type: 'boolean',
desc: 'Orphan all resources for which the rollback operation fails.',
},
'validate-bootstrap-version': {
type: 'boolean',
desc: 'Whether to validate the bootstrap stack version. Defaults to \'true\', disable with --no-validate-bootstrap-version.',
},
'orphan': {
// alias: 'o' conflicts with --output
type: 'array',
desc: 'Orphan the given resources, identified by their logical ID (can be specified multiple times)',
default: [],
},
},
},
'import': {
description: 'Import existing resource(s) into the given STACK',
arg: {
name: 'STACK',
variadic: false,
},
options: {
'execute': { type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true },
'change-set-name': { type: 'string', desc: 'Name of the CloudFormation change set to create' },
'toolkit-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack to create', requiresArg: true },
'rollback': {
type: 'boolean',
desc: "Rollback stack to stable state on failure. Defaults to 'true', iterate more rapidly with --no-rollback or -R. " +
'Note: do **not** disable this flag for deployments with resource replacements, as that will always fail',
},
'force': {
alias: 'f',
type: 'boolean',
desc: 'Do not abort if the template diff includes updates or deletes. This is probably safe but we\'re not sure, let us know how it goes.',
},
'record-resource-mapping': {
type: 'string',
alias: 'r',
requiresArg: true,
desc: 'If specified, CDK will generate a mapping of existing physical resources to CDK resources to be imported as. The mapping ' +
'will be written in the given file path. No actual import operation will be performed',
},
'resource-mapping': {
type: 'string',
alias: 'm',
requiresArg: true,
desc: 'If specified, CDK will use the given file to map physical resources to CDK resources for import, instead of interactively ' +
'asking the user. Can be run from scripts',
},
},
},
'watch': {
description: "Shortcut for 'deploy --watch'",
arg: {
name: 'STACKS',
variadic: true,
},
options: {
'build-exclude': { type: 'array', alias: 'E', desc: 'Do not rebuild asset with the given ID. Can be specified multiple times', default: [] },
'exclusively': { type: 'boolean', alias: 'e', desc: 'Only deploy requested stacks, don\'t include dependencies' },
'change-set-name': { type: 'string', desc: 'Name of the CloudFormation change set to create' },
'force': { alias: 'f', type: 'boolean', desc: 'Always deploy stack even if templates are identical', default: false },
'toolkit-stack-name': { type: 'string', desc: 'The name of the existing CDK toolkit stack (only used for app using legacy synthesis)', requiresArg: true },
'progress': { type: 'string', choices: [StackActivityProgress.BAR, StackActivityProgress.EVENTS], desc: 'Display mode for stack activity events' },
'rollback': {
type: 'boolean',
desc: "Rollback stack to stable state on failure. Defaults to 'true', iterate more rapidly with --no-rollback or -R. " +
'Note: do **not** disable this flag for deployments with resource replacements, as that will always fail',
negativeAlias: 'R',
},
'hotswap': {
type: 'boolean',
desc: "Attempts to perform a 'hotswap' deployment, " +
'but does not fall back to a full deployment if that is not possible. ' +
'Instead, changes to any non-hotswappable properties are ignored.' +
"'true' by default, use --no-hotswap to turn off",
},
'hotswap-fallback': {
type: 'boolean',
desc: "Attempts to perform a 'hotswap' deployment, " +
'which skips CloudFormation and updates the resources directly, ' +
'and falls back to a full deployment if that is not possible.',
},
'hotswap-ecs-minimum-healthy-percent': {
type: 'number',
desc: 'Lower limit on the number of your service\'s tasks that must remain in the RUNNING state during a deployment, as a percentage of the desiredCount',
},
'hotswap-ecs-maximum-healthy-percent': {
type: 'number',
desc: 'Upper limit on the number of your service\'s tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desiredCount',
},
'hotswap-ecs-stabilization-timeout-seconds': {
type: 'number',
desc: 'Number of seconds to wait for a single service to reach stable state, where the desiredCount is equal to the runningCount',
},
'logs': {
type: 'boolean',
default: true,
desc: 'Show CloudWatch log events from all resources in the selected Stacks in the terminal. ' +
"'true' by default, use --no-logs to turn off",
},
'concurrency': { type: 'number', desc: 'Maximum number of simultaneous deployments (dependency permitting) to execute.', default: 1, requiresArg: true },
},
},
'destroy': {
description: 'Destroy the stack(s) named STACKS',
arg: {
name: 'STACKS',
variadic: true,
},
options: {
all: { type: 'boolean', default: false, desc: 'Destroy all available stacks' },
exclusively: { type: 'boolean', alias: 'e', desc: 'Only destroy requested stacks, don\'t include dependees' },
force: { type: 'boolean', alias: 'f', desc: 'Do not ask for confirmation before destroying the stacks' },
},
},
'diff': {
description: 'Compares the specified stack with the deployed stack or a local template file, and returns with status 1 if any difference is found',
arg: {
name: 'STACKS',
variadic: true,
},
options: {
'exclusively': { type: 'boolean', alias: 'e', desc: 'Only diff requested stacks, don\'t include dependencies' },
'context-lines': { type: 'number', desc: 'Number of context lines to include in arbitrary JSON diff rendering', default: 3, requiresArg: true },
'template': { type: 'string', desc: 'The path to the CloudFormation template to compare with', requiresArg: true },
'strict': { type: 'boolean', desc: 'Do not filter out AWS::CDK::Metadata resources, mangled non-ASCII characters, or the CheckBootstrapVersionRule', default: false },
'security-only': { type: 'boolean', desc: 'Only diff for broadened security changes', default: false },
'fail': { type: 'boolean', desc: 'Fail with exit code 1 in case of diff' },
'processed': { type: 'boolean', desc: 'Whether to compare against the template with Transforms already processed', default: false },
'quiet': { type: 'boolean', alias: 'q', desc: 'Do not print stack name and default message when there is no diff to stdout', default: false },
'change-set': { type: 'boolean', alias: 'changeset', desc: 'Whether to create a changeset to analyze resource replacements. In this mode, diff will use the deploy role instead of the lookup role.', default: true },
'import-existing-resources': { type: 'boolean', desc: 'Whether or not the change set imports resources that already exist', default: false },
'include-moves': { type: 'boolean', desc: 'Whether to include moves in the diff', default: false },
},
},
'drift': {
description: 'Detect drifts in the given CloudFormation stack(s)',
arg: {
name: 'STACKS',
variadic: true,
},
options: {
fail: { type: 'boolean', desc: 'Fail with exit code 1 if drift is detected' },
},
},
'metadata': {
description: 'Returns all metadata associated with this stack',
arg: {
name: 'STACK',
variadic: false,
},
},
'acknowledge': {
aliases: ['ack'],
description: 'Acknowledge a notice so that it does not show up anymore',
arg: {
name: 'ID',
variadic: false,
},
},
'notices': {
description: 'Returns a list of relevant notices',
options: {
unacknowledged: { type: 'boolean', alias: 'u', default: false, desc: 'Returns a list of unacknowledged notices' },
},
},
'init': {
description: 'Create a new, empty CDK project from a template.',
arg: {
name: 'TEMPLATE',
variadic: false,
},
options: {
'language': { type: 'string', alias: 'l', desc: 'The language to be used for the new project (default can be configured in ~/.cdk.json)', choices: await availableInitLanguages() },
'list': { type: 'boolean', desc: 'List the available templates' },
'generate-only': { type: 'boolean', default: false, desc: 'If true, only generates project files, without executing additional operations such as setting up a git repo, installing dependencies or compiling the project' },
'lib-version': { type: 'string', alias: 'V', default: undefined, desc: 'The version of the CDK library (aws-cdk-lib) to initialize built-in templates with. Defaults to the version that was current when this CLI was built.' },
'from-path': { type: 'string', desc: 'Path to a local custom template directory or multi-template repository', requiresArg: true, conflicts: ['lib-version'] },
'template-path': { type: 'string', desc: 'Path to a specific template within a multi-template repository', requiresArg: true },
'package-manager': { type: 'string', desc: 'The package manager to use to install dependencies. Only applicable for TypeScript and JavaScript projects. Defaults to npm in TypeScript and JavaScript projects.', choices: JS_PACKAGE_MANAGERS.map(({ name }) => name) },
},
implies: { 'template-path': 'from-path' },
},
'migrate': {
description: 'Migrate existing AWS resources into a CDK app',
options: {
'stack-name': { type: 'string', alias: 'n', desc: 'The name assigned to the stack created in the new project. The name of the app will be based off this name as well.', requiresArg: true },
'language': {
type: 'string',
default: 'typescript',
alias: 'l',
desc: 'The language to be used for the new project',
choices: [...new Set(cdk_from_cfn.supported_languages().flatMap((lang) => [lang, getLanguageAlias(lang)]))],
},
'account': { type: 'string', desc: 'The account to retrieve the CloudFormation stack template from' },
'region': { type: 'string', desc: 'The region to retrieve the CloudFormation stack template from' },
'from-path': { type: 'string', desc: 'The path to the CloudFormation template to migrate. Use this for locally stored templates' },
'from-stack': { type: 'boolean', desc: 'Use this flag to retrieve the template for an existing CloudFormation stack' },
'output-path': { type: 'string', desc: 'The output path for the migrated CDK app' },
'from-scan': {
type: 'string',
desc: 'Determines if a new scan should be created, or the last successful existing scan should be used ' +
'\n options are "new" or "most-recent"',
},
'filter': {
type: 'array',
desc: 'Filters the resource scan based on the provided criteria in the following format: "key1=value1,key2=value2"' +
'\n This field can be passed multiple times for OR style filtering: ' +
'\n filtering options: ' +
'\n resource-identifier: A key-value pair that identifies the target resource. i.e. {"ClusterName", "myCluster"}' +
'\n resource-type-prefix: A string that represents a type-name prefix. i.e. "AWS::DynamoDB::"' +
'\n tag-key: a string that matches resources with at least one tag with the provided key. i.e. "myTagKey"' +
'\n tag-value: a string that matches resources with at least one tag with the provided value. i.e. "myTagValue"',
},
'compress': { type: 'boolean', desc: 'Use this flag to zip the generated CDK app' },
},
},
'context': {
description: 'Manage cached context values',
options: {
reset: { alias: 'e', desc: 'The context key (or its index) to reset', type: 'string', requiresArg: true, default: undefined },
force: { alias: 'f', desc: 'Ignore missing key error', type: 'boolean', default: false },
clear: { desc: 'Clear all context', type: 'boolean', default: false },
},
},
'docs': {
aliases: ['doc'],
description: 'Opens the reference documentation in a browser',
options: {
browser: {
alias: 'b',
desc: 'the command to use to open the browser, using %u as a placeholder for the path of the file to open',
type: 'string',
default: YARGS_HELPERS.browserForPlatform(),
},
},
},
'doctor': {
description: 'Check your set-up for potential problems',
},
'refactor': {
description: 'Moves resources between stacks or within the same stack',
options: {
'additional-stack-name': {
type: 'array',
requiresArg: true,
desc: 'Names of deployed stacks to be considered for resource comparison.',
},
'dry-run': {
type: 'boolean',
desc: 'Do not perform any changes, just show what would be done',
default: false,
},
'override-file': {
type: 'string',
requiresArg: true,
desc: 'A file that declares overrides to be applied to the list of mappings computed by the CLI.',
},
'revert': {
type: 'boolean',
default: false,
desc: 'If specified, the command will revert the refactor operation. This is only valid if a mapping file was provided.',
},
'force': {
type: 'boolean',
default: false,
desc: 'Whether to do the refactor without asking for confirmation',
},
},
arg: {
name: 'STACKS',
variadic: true,
},
},
'cli-telemetry': {
description: 'Enable or disable anonymous telemetry',
options: {
enable: {
type: 'boolean',
desc: 'Enable anonymous telemetry',
conflicts: 'disable',
},
disable: {
type: 'boolean',
desc: 'Disable anonymous telemetry',
conflicts: 'enable',
},
status: {
type: 'boolean',
desc: 'Report telemetry opt-in/out status',
conflicts: ['enable', 'disable'],
},
},
},
},
};
}