prefer-cdk-method-direct-in-development
Flags development cdk deploy commands that do not use --method=direct.
Why it matters
- By default,
cdk deploycreates and executes a CloudFormation change set, which can add 6-15 seconds per stack before the deployment starts. --method=directapplies the change immediately throughCreateStackorUpdateStack, skipping change set creation while still performing a full CloudFormation deployment with automatic rollback and stabilization.- It is orthogonal to
--express, which additionally skips stabilization waits, and the two can be combined.
What it flags
- Workflow steps and package.json development scripts that run
cdk deploywithout specifying a deployment method. - Commands that already pass a method (
--method/-m) are not flagged. - Commands that require a change set (
--change-set-name,--import-existing-resources,--revert-drift) are not flagged. aws-cdkCLI below 2.118.0 is not flagged, because--method=directcould fail withNo updates are to be performedon stacks that resolve SSM parameters (fixed in 2.118.0).- Production and release contexts are not flagged.
Suggested action
- Add
--method=directto developmentcdk deploycommands.
Verification
- Compare deployment wall-clock time before and after switching to
--method=direct, and confirm that no change-set review or tooling depends on the change set.
Compatibility notes
--method=directand--expressare orthogonal and can be combined:cdk deploy --method=direct --express.- When a development deploy omits both
--expressand--method=direct, the report shows the express-mode finding at that step, because findings at the same file and line are collapsed. This rule surfaces once express mode is already in place, or when--expressis not applicable.