You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cli): array arguments in cdk.json are ignored (#33107)
### Issue # (if applicable)
Closes#32814
### Reason for this change
yargs treats arrays weirdly. setting `default: undefined` results in the default array as `['undefined']`. So instead, I set the default to be `default: []`. However, this triggers an issue with the order of combining all arguments, and the CLI default was overriding any values in `cdk.json` for array types. So instead, we must omit the `default` property entirely for arrays, in order to achieve the desired behavior of `undefined` as default.
### Description of changes
Updated code generation to generate NO default property for array types
### Description of how you validated changes
tests in `user-input-gen` and the diff of `parse-command-line-arguments.ts` show that unless already defined, we are omitting defaults for arrays
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
desc: 'Name or path of a node package that extend the CDK features. Can be specified multiple times',
@@ -151,9 +149,9 @@ export function parseCommandLineArguments(args: Array<string>): any {
151
149
desc: 'Force CI detection. If CI=true then logs will be sent to stdout instead of stderr',
152
150
})
153
151
.option('unstable',{
154
-
default: [],
155
152
type: 'array',
156
153
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.',
154
+
default: [],
157
155
nargs: 1,
158
156
requiresArg: true,
159
157
})
@@ -237,10 +235,10 @@ export function parseCommandLineArguments(args: Array<string>): any {
237
235
desc: 'Block public access configuration on CDK toolkit bucket (enabled by default) ',
238
236
})
239
237
.option('tags',{
240
-
default: [],
241
238
type: 'array',
242
239
alias: 't',
243
240
desc: 'Tags to add for the stack (KEY=VALUE)',
241
+
default: [],
244
242
nargs: 1,
245
243
requiresArg: true,
246
244
})
@@ -250,30 +248,30 @@ export function parseCommandLineArguments(args: Array<string>): any {
250
248
desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)',
251
249
})
252
250
.option('trust',{
253
-
default: [],
254
251
type: 'array',
255
252
desc: 'The AWS account IDs that should be trusted to perform deployments into this environment (may be repeated, modern bootstrapping only)',
253
+
default: [],
256
254
nargs: 1,
257
255
requiresArg: true,
258
256
})
259
257
.option('trust-for-lookup',{
260
-
default: [],
261
258
type: 'array',
262
259
desc: 'The AWS account IDs that should be trusted to look up values in this environment (may be repeated, modern bootstrapping only)',
260
+
default: [],
263
261
nargs: 1,
264
262
requiresArg: true,
265
263
})
266
264
.option('untrust',{
267
-
default: [],
268
265
type: 'array',
269
266
desc: 'The AWS account IDs that should not be trusted by this environment (may be repeated, modern bootstrapping only)',
267
+
default: [],
270
268
nargs: 1,
271
269
requiresArg: true,
272
270
})
273
271
.option('cloudformation-execution-policies',{
274
-
default: [],
275
272
type: 'array',
276
273
desc: 'The Managed Policy ARNs that should be attached to the role performing deployments into this environment (may be repeated, modern bootstrapping only)',
274
+
default: [],
277
275
nargs: 1,
278
276
requiresArg: true,
279
277
})
@@ -356,10 +354,10 @@ export function parseCommandLineArguments(args: Array<string>): any {
356
354
desc: 'Deploy all available stacks',
357
355
})
358
356
.option('build-exclude',{
359
-
default: [],
360
357
type: 'array',
361
358
alias: 'E',
362
359
desc: 'Do not rebuild asset with the given ID. Can be specified multiple times',
360
+
default: [],
363
361
nargs: 1,
364
362
requiresArg: true,
365
363
})
@@ -382,7 +380,6 @@ export function parseCommandLineArguments(args: Array<string>): any {
382
380
requiresArg: true,
383
381
})
384
382
.option('tags',{
385
-
default: [],
386
383
type: 'array',
387
384
alias: 't',
388
385
desc: 'Tags to add to the stack (KEY=VALUE), overrides tags from Cloud Assembly (deprecated)',
@@ -420,9 +417,9 @@ export function parseCommandLineArguments(args: Array<string>): any {
420
417
desc: 'Always deploy stack even if templates are identical',
421
418
})
422
419
.option('parameters',{
423
-
default: {},
424
420
type: 'array',
425
421
desc: 'Additional parameters passed to CloudFormation at deploy time (STACK:KEY=VALUE)',
422
+
default: {},
426
423
nargs: 1,
427
424
requiresArg: true,
428
425
})
@@ -524,9 +521,9 @@ export function parseCommandLineArguments(args: Array<string>): any {
524
521
desc: "Whether to validate the bootstrap stack version. Defaults to 'true', disable with --no-validate-bootstrap-version.",
525
522
})
526
523
.option('orphan',{
527
-
default: [],
528
524
type: 'array',
529
525
desc: 'Orphan the given resources, identified by their logical ID (can be specified multiple times)',
526
+
default: [],
530
527
nargs: 1,
531
528
requiresArg: true,
532
529
}),
@@ -578,10 +575,10 @@ export function parseCommandLineArguments(args: Array<string>): any {
578
575
.command('watch [STACKS..]',"Shortcut for 'deploy --watch'",(yargs: Argv)=>
579
576
yargs
580
577
.option('build-exclude',{
581
-
default: [],
582
578
type: 'array',
583
579
alias: 'E',
584
580
desc: 'Do not rebuild asset with the given ID. Can be specified multiple times',
581
+
default: [],
585
582
nargs: 1,
586
583
requiresArg: true,
587
584
})
@@ -796,7 +793,6 @@ export function parseCommandLineArguments(args: Array<string>): any {
796
793
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"',
797
794
})
798
795
.option('filter',{
799
-
default: [],
800
796
type: 'array',
801
797
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"',
0 commit comments