(aws-cdk): Allow CLI to reuse cdk.out on subsequent commands #32244
Labels
effort/medium
Medium work item – several days of effort
feature-request
A feature should be added or improved.
p2
package/tools
Related to AWS CDK Tools or CLI
Describe the feature
When I call
cdk <action>
, I should have the option (non-default) to tell the cdk to use the existing CloudAssembly in the output directory.Example:
cdk synth # This command would skip all of the CloudAssembly synthesis time because it would just load what is there cdk diff --reuse-out -e my-stackA
Use Case
Currently, if I run
cdk synth
and thencdk diff stack-a
orcdk deploy
, etc. The entire CDK app is rendered out completely before the actual diff or deploy function is done. As a default state, I have no issue with this, since that guarantees that I didn't change any CDK code and have stale output.However, with growing CDK apps (especially those that might write a lot of data, like EKS clusters with manifests or dashboard templates), running multiple cdk commands becomes an expensive chore (we're talking up to 5-10 minutes of additional lost time given larger grouping). For both controlled CD environments (where I may want to run synth, maybe output a diff, and then deploy) and local development/troubleshooting (where you might want to run many separate stack diffs as you verify something), it would be very helpful to have a top-level flag like:
--reuse-out
, that would allow subsequent calls to operate on the same output from a previous synth step.Proposed Solution
I have implemented something like this already, albeit in a very hacked way.
Ideally, we would just update the cli.js file
aws-cdk
to:out
directory and just use cxapi.CloudAssembly to load the assembly and return without re-running the execProgram() functionAs a matter of safety, we would write out a warning to console to notify that we are doing this, and we could even print a summary of stacks, etc. for a double check. I think by making this feature opt-in, the developer is taking an active role in double-checking when they call it.
Other Information
No response
Acknowledgements
CDK version used
2.169.0
Environment details (OS name and version, etc.)
mac and pop_os
The text was updated successfully, but these errors were encountered: