Skip to content

Commit c091f72

Browse files
vivian12300rix0rrr
authored andcommitted
feat(cli): allow users to enable all feature flags that do not impact their application (#798)
Allows users to run `cdk flags --safe` to set all unconfigured feature flags to their recommended states without changing their CloudFormation template. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Co-authored-by: Rico Huijbers <[email protected]>
1 parent b5cb197 commit c091f72

File tree

19 files changed

+1257
-115
lines changed

19 files changed

+1257
-115
lines changed

.projenrc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ const cli = configureProject(
11611161
'glob',
11621162
'minimatch',
11631163
'p-limit@^3',
1164+
'p-queue@^6',
11641165
'promptly',
11651166
'proxy-agent',
11661167
'semver',

packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22090,6 +22090,32 @@ SOFTWARE.
2209022090

2209122091

2209222092

22093+
----------------
22094+
22095+
** [email protected] - https://www.npmjs.com/package/eventemitter3/v/4.0.7 | MIT
22096+
The MIT License (MIT)
22097+
22098+
Copyright (c) 2014 Arnout Kazemier
22099+
22100+
Permission is hereby granted, free of charge, to any person obtaining a copy
22101+
of this software and associated documentation files (the "Software"), to deal
22102+
in the Software without restriction, including without limitation the rights
22103+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22104+
copies of the Software, and to permit persons to whom the Software is
22105+
furnished to do so, subject to the following conditions:
22106+
22107+
The above copyright notice and this permission notice shall be included in all
22108+
copies or substantial portions of the Software.
22109+
22110+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22111+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22112+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22113+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22114+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22115+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22116+
SOFTWARE.
22117+
22118+
2209322119
----------------
2209422120

2209522121
** [email protected] - https://www.npmjs.com/package/fast-deep-equal/v/3.1.3 | MIT
@@ -22846,6 +22872,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2284622872
THE SOFTWARE.
2284722873

2284822874

22875+
----------------
22876+
22877+
** [email protected] - https://www.npmjs.com/package/p-finally/v/1.0.0 | MIT
22878+
The MIT License (MIT)
22879+
22880+
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
22881+
22882+
Permission is hereby granted, free of charge, to any person obtaining a copy
22883+
of this software and associated documentation files (the "Software"), to deal
22884+
in the Software without restriction, including without limitation the rights
22885+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22886+
copies of the Software, and to permit persons to whom the Software is
22887+
furnished to do so, subject to the following conditions:
22888+
22889+
The above copyright notice and this permission notice shall be included in
22890+
all copies or substantial portions of the Software.
22891+
22892+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22893+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22894+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22895+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22896+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22897+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22898+
THE SOFTWARE.
22899+
22900+
2284922901
----------------
2285022902

2285122903
** [email protected] - https://www.npmjs.com/package/p-limit/v/2.3.0 | MIT
@@ -22888,6 +22940,34 @@ The above copyright notice and this permission notice shall be included in all c
2288822940
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2288922941

2289022942

22943+
----------------
22944+
22945+
** [email protected] - https://www.npmjs.com/package/p-queue/v/6.6.2 | MIT
22946+
MIT License
22947+
22948+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
22949+
22950+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
22951+
22952+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22953+
22954+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22955+
22956+
22957+
----------------
22958+
22959+
** [email protected] - https://www.npmjs.com/package/p-timeout/v/3.2.0 | MIT
22960+
MIT License
22961+
22962+
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
22963+
22964+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
22965+
22966+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22967+
22968+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22969+
22970+
2289122971
----------------
2289222972

2289322973
** [email protected] - https://www.npmjs.com/package/p-try/v/2.2.0 | MIT

packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,3 +1393,4 @@ export class Toolkit extends CloudAssemblySourceBuilder {
13931393
}
13941394
}
13951395
}
1396+

packages/aws-cdk/.projen/deps.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/aws-cdk/THIRD_PARTY_LICENSES

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21883,6 +21883,32 @@ SOFTWARE.
2188321883

2188421884

2188521885

21886+
----------------
21887+
21888+
** [email protected] - https://www.npmjs.com/package/eventemitter3/v/4.0.7 | MIT
21889+
The MIT License (MIT)
21890+
21891+
Copyright (c) 2014 Arnout Kazemier
21892+
21893+
Permission is hereby granted, free of charge, to any person obtaining a copy
21894+
of this software and associated documentation files (the "Software"), to deal
21895+
in the Software without restriction, including without limitation the rights
21896+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21897+
copies of the Software, and to permit persons to whom the Software is
21898+
furnished to do so, subject to the following conditions:
21899+
21900+
The above copyright notice and this permission notice shall be included in all
21901+
copies or substantial portions of the Software.
21902+
21903+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21904+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21905+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21906+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21907+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21908+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21909+
SOFTWARE.
21910+
21911+
2188621912
----------------
2188721913

2188821914
** [email protected] - https://www.npmjs.com/package/fast-deep-equal/v/3.1.3 | MIT
@@ -22639,6 +22665,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2263922665
THE SOFTWARE.
2264022666

2264122667

22668+
----------------
22669+
22670+
** [email protected] - https://www.npmjs.com/package/p-finally/v/1.0.0 | MIT
22671+
The MIT License (MIT)
22672+
22673+
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
22674+
22675+
Permission is hereby granted, free of charge, to any person obtaining a copy
22676+
of this software and associated documentation files (the "Software"), to deal
22677+
in the Software without restriction, including without limitation the rights
22678+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22679+
copies of the Software, and to permit persons to whom the Software is
22680+
furnished to do so, subject to the following conditions:
22681+
22682+
The above copyright notice and this permission notice shall be included in
22683+
all copies or substantial portions of the Software.
22684+
22685+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22686+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22687+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22688+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22689+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22690+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22691+
THE SOFTWARE.
22692+
22693+
2264222694
----------------
2264322695

2264422696
** [email protected] - https://www.npmjs.com/package/p-limit/v/2.3.0 | MIT
@@ -22681,6 +22733,34 @@ The above copyright notice and this permission notice shall be included in all c
2268122733
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2268222734

2268322735

22736+
----------------
22737+
22738+
** [email protected] - https://www.npmjs.com/package/p-queue/v/6.6.2 | MIT
22739+
MIT License
22740+
22741+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
22742+
22743+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
22744+
22745+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22746+
22747+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22748+
22749+
22750+
----------------
22751+
22752+
** [email protected] - https://www.npmjs.com/package/p-timeout/v/3.2.0 | MIT
22753+
MIT License
22754+
22755+
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
22756+
22757+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
22758+
22759+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22760+
22761+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22762+
22763+
2268422764
----------------
2268522765

2268622766
** [email protected] - https://www.npmjs.com/package/p-try/v/2.2.0 | MIT

packages/aws-cdk/lib/cli/cli-config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ export async function makeConfig(): Promise<CliConfig> {
129129
unconfigured: { type: 'boolean', desc: 'Modify unconfigured feature flags', requiresArg: false },
130130
recommended: { type: 'boolean', desc: 'Change flags to recommended states', requiresArg: false },
131131
default: { type: 'boolean', desc: 'Change flags to default state', requiresArg: false },
132-
interactive: { type: 'boolean', alias: ['i'], desc: 'Interactive option for the flags command', requiresArg: false },
132+
interactive: { type: 'boolean', alias: ['i'], desc: 'Interactive option for the flags command' },
133+
safe: { type: 'boolean', desc: 'Enable all feature flags that do not impact the user\'s application', requiresArg: false },
134+
concurrency: { type: 'number', alias: ['n'], desc: 'Maximum number of simultaneous synths to execute.', default: 4, requiresArg: true },
133135
},
134136
},
135137
'deploy': {

packages/aws-cdk/lib/cli/cli-type-registry.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,21 @@
383383
"alias": [
384384
"i"
385385
],
386-
"desc": "Interactive option for the flags command",
386+
"desc": "Interactive option for the flags command"
387+
},
388+
"safe": {
389+
"type": "boolean",
390+
"desc": "Enable all feature flags that do not impact the user's application",
387391
"requiresArg": false
392+
},
393+
"concurrency": {
394+
"type": "number",
395+
"alias": [
396+
"n"
397+
],
398+
"desc": "Maximum number of simultaneous synths to execute.",
399+
"default": 4,
400+
"requiresArg": true
388401
}
389402
}
390403
},

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import type { Settings } from '../api/settings';
2626
import { contextHandler as context } from '../commands/context';
2727
import { docs } from '../commands/docs';
2828
import { doctor } from '../commands/doctor';
29-
import { handleFlags } from '../commands/flag-operations';
29+
import { FlagCommandHandler } from '../commands/flags/flags';
3030
import { cliInit, printAvailableTemplates } from '../commands/init';
3131
import { getMigrateScanType } from '../commands/migrate';
3232
import { execProgram, CloudExecutable } from '../cxapp';
@@ -501,7 +501,8 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
501501
unstableFeatures: configuration.settings.get(['unstable']),
502502
});
503503
const flagsData = await toolkit.flags(cloudExecutable);
504-
return handleFlags(flagsData, ioHelper, args, toolkit);
504+
const handler = new FlagCommandHandler(flagsData, ioHelper, args, toolkit);
505+
return handler.processFlagsCommand();
505506

506507
case 'synthesize':
507508
case 'synth':

packages/aws-cdk/lib/cli/convert-to-user-input.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ export function convertYargsToUserInput(args: any): UserInput {
105105
recommended: args.recommended,
106106
default: args.default,
107107
interactive: args.interactive,
108+
safe: args.safe,
109+
concurrency: args.concurrency,
108110
FLAGNAME: args.FLAGNAME,
109111
};
110112
break;
@@ -391,6 +393,8 @@ export function convertConfigToUserInput(config: any): UserInput {
391393
recommended: config.flags?.recommended,
392394
default: config.flags?.default,
393395
interactive: config.flags?.interactive,
396+
safe: config.flags?.safe,
397+
concurrency: config.flags?.concurrency,
394398
};
395399
const deployOptions = {
396400
all: config.deploy?.all,

packages/aws-cdk/lib/cli/parse-command-line-arguments.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,19 @@ export function parseCommandLineArguments(args: Array<string>): any {
409409
type: 'boolean',
410410
alias: ['i'],
411411
desc: 'Interactive option for the flags command',
412+
})
413+
.option('safe', {
414+
default: undefined,
415+
type: 'boolean',
416+
desc: "Enable all feature flags that do not impact the user's application",
412417
requiresArg: false,
418+
})
419+
.option('concurrency', {
420+
default: 4,
421+
type: 'number',
422+
alias: ['n'],
423+
desc: 'Maximum number of simultaneous synths to execute.',
424+
requiresArg: true,
413425
}),
414426
)
415427
.command('deploy [STACKS..]', 'Deploys the stack(s) named STACKS into your AWS account', (yargs: Argv) =>

0 commit comments

Comments
 (0)