aws-cdk: [CLI]package/tools: Force deploy flag does not work
Running cdk deploy stack-name --require-approval never --force does not work. Specifically its skips updating the stack with (no changes) outputted in the command line. I’ve also tried the following patterns:
cdk deploy stack-name --forcecdk deploy --force stack-name
Reproduction Steps
Repo is private so cannot link but simply running one of the above commands with cdk toolkit version 1.108.0 should suffice. I can try and reproduce in a public repo if the person seeing this cannot reproduce.
What did you expect to happen?
CDK would never skip updating stacks due to “no changes” in the template when the --force flag is passed.
What actually happened?
CDK skips updating stacks due to “no changes” in the template when the --force flag is passed.
Environment
- **CDK CLI Version: ** 1.108.0
- Framework Version: 1.108.0
- Node.js Version: v12.22.0
- OS : MacOs Big Sur
- Language (Version): TS 4.2.4
Other
✅ service-name (no changes)
This is 🐛 Bug Report
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 20
- Comments: 15 (3 by maintainers)
Commits related to this issue
- chore(cli): warn about a useless `--force` flag People expect the `--force` flag to do something that it doesn't do. Explicitly warn them about that behavior when it happens. Relates to #15065. — committed to aws/aws-cdk by rix0rrr 3 years ago
- chore(cli): warn about a useless `--force` flag (#28150) People expect the `--force` flag to do something that it doesn't do. Explicitly warn them about that behavior when it happens. Relates to #15... — committed to aws/aws-cdk by rix0rrr 3 years ago
cdk deploy --forceshould force cloudformation to redeploy without consider the change-sets.I have tested it. A codepipeline is created by my cdk project. Then I add a step manually in the codepipeline, and redeploy cdk project to force it change back to the defined stage. However,
cdk deploy --forceis not working as expected. From cloudformation point of view, nothing is change. That’s mean, this--forceoption is helpless.I agree with @jefftham , we should be able to overwrite the Cloudformation rule using --force, to literally force to deploy.
@Lockoo You only need to add
--require-approval neveras argument aftercdk deploy. If you want more option typecdk deploy --helpand search the option--require-approvalany updates on this? it’s a really annoying issue that this flag doesn’t actually work
Hi everyone on this issue,
Please run the command again with
-v:And observe the additional logged output.
skipping deployment (use --force to override), then CDK has short-circuited the deployment because it thinks there is nothing to do. It is usually right, but there might be cases in which it is wrong, and you can use--forceto force it to update.No changes are to be performed on <STACK>, then CloudFormation considers the change to have no effects, and in fact if we had told CloudFormation to execute it would have given us back an error. There is just nothing to do for CloudFormation, and CDK cannot change that fact.If you are planning to use
--forceto wipe away drift (that is: you’ve changed resources out-of-band, and now want to get them back into the state as declared in the template), then be aware: this is not possible. CloudFormation does not support wiping away drift in this matter. It exclusively operates on its own view of the world which it has built up over deployments done via CloudFormation, and it will not look at operations done in the mean time via the console or the CLI. If this is what you want to do, you need to look at the CloudFormation Drift Detection feature.I have the same use case - I want
cdk deployto re-deploy the stack even if there are no changes in the CFN template. My stack just simply builds a docker container and uploads it to ECR - while the Dockerfile itself doesn’t change, the dependencies that it will be pulling viapipwill be updated, so I want it to re-build.I found https://github.com/aws/aws-cdk/issues/8493 which claims that you can do this with
cdk deploy --method direct, but this didn’t work for me (nor didcdk deploy --force).