feat(cli): add cdk deploy --method=execute-change-set for two-step deployment workflows - #1271
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1271 +/- ##
==========================================
+ Coverage 88.14% 88.31% +0.17%
==========================================
Files 74 74
Lines 10481 10541 +60
Branches 1432 1452 +20
==========================================
+ Hits 9238 9309 +71
+ Misses 1216 1204 -12
- Partials 27 28 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… workflows Add a new `--method=execute-change-set` option to `cdk deploy` that executes a previously created change set. This completes the two-step deployment workflow: 1. `cdk deploy MyStack --method=prepare-change-set` 2. Review the change set (AWS Console, CLI, or external tooling) 3. `cdk deploy MyStack --method=execute-change-set` The change set name defaults to `cdk-deploy-change-set` (matching `prepare-change-set`), or can be set with `--change-set-name`. Options that only affect change set creation (`--force`, `--parameters`, `--import-existing-resources`, `--revert-drift`) are rejected with a clear error. Exactly one stack must be specified.
| $ # Step 2: Review the change set (e.g., in the AWS Console or via CLI) | ||
|
|
||
| $ # Step 3: Execute the change set | ||
| $ cdk deploy MyStack --method=execute-change-set |
There was a problem hiding this comment.
Is the change set name mandatory?
There was a problem hiding this comment.
@otaviomacedo it's optional, see next line:
A custom change set name can be provided with
--change-set-namein both steps.
|
This is a nice addition, but it doesn't address the core issue raised in #1123. Ideally, there should be a more restrictive role that can prepare the changeset without having permission to also execute it. |
Two-step deployment workflows with
--method=execute-change-setProblem
CDK supports creating change sets without executing them via
--method=prepare-change-set, but there is no way to execute those change sets through CDK afterwards. Users who want a review-then-deploy workflow — common in regulated environments and CI/CD pipelines with manual approval gates — have to drop down to raw CloudFormation API calls or the AWS Console to execute the change set. This breaks the CDK abstraction and loses CDK's progress monitoring, approval prompts, and error handling.Use case
Teams that require human review of infrastructure changes before deployment need a complete workflow within CDK:
This is especially valuable for:
What this PR does
--method=execute-change-settocdk deploycdk-deploy-change-set(matchingprepare-change-set), so the simplest workflow needs no extra flags--force,--parameters,--import-existing-resources,--revert-drift) with clear errorsExecuteChangeSetDeploymentas part of the publicDeploymentMethodtype in@aws-cdk/toolkit-libChecklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license