Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI]package/tools: Force deploy flag does not work #15065

Open
covertbert opened this issue Jun 10, 2021 · 12 comments
Open

[CLI]package/tools: Force deploy flag does not work #15065

covertbert opened this issue Jun 10, 2021 · 12 comments
Labels
bug This issue is a bug. p1 package/tools Related to AWS CDK Tools or CLI

Comments

@covertbert
Copy link

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 --force
  • cdk 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

@covertbert covertbert added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 10, 2021
@peterwoodworth peterwoodworth added the package/tools Related to AWS CDK Tools or CLI label Jun 11, 2021
@peterwoodworth
Copy link
Contributor

I can't seem to reproduce this, what changes did you make to your stack?

@peterwoodworth peterwoodworth added p2 needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 11, 2021
@covertbert
Copy link
Author

covertbert commented Jun 11, 2021

I didn't make any changes to my stack. My understanding is that the point of the force flag is that it will at least trigger Cloudformation regardless of whether you've changed anything and then Cloudformation will determine what needs updating and what doesn't. In reality, for me at least, the CDK CLI just skips it completely because the template has not changed and Cloudformation is never triggered.

@jefftham
Copy link

cdk deploy --force should 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 --force is not working as expected. From cloudformation point of view, nothing is change.
That's mean, this --force option is helpless.

@covertbert
Copy link
Author

Agreed @jefftham it seems as if this flag cannot work as a user would expect it to work.

@markus-ethur
Copy link

I agree with @jefftham , we should be able to overwrite the Cloudformation rule using --force, to literally force to deploy.

@TheRealAmazonKendra TheRealAmazonKendra removed the needs-reproduction This issue needs reproduction. label Jan 26, 2023
@TheRealAmazonKendra TheRealAmazonKendra changed the title package/tools: Force deploy flag does not work [CLI]package/tools: Force deploy flag does not work Jan 26, 2023
@TheRealAmazonKendra TheRealAmazonKendra added p1 and removed p2 labels Jan 26, 2023
@Lockoo
Copy link

Lockoo commented Mar 26, 2023

any updates on this? it's a really annoying issue that this flag doesn't actually work

@elmorgan3
Copy link

@Lockoo You only need to add --require-approval never as argument after cdk deploy.
If you want more option type cdk deploy --help and search the option --require-approval

@Lockoo
Copy link

Lockoo commented Apr 12, 2023

@Lockoo You only need to add --require-approval never as argument after cdk deploy. If you want more option type cdk deploy --help and search the option --require-approval

this won't trigger a deploy if there are no changes, it just doesnt need approval to deploy when there are.

@awerchniak
Copy link

I have the same use case - I want cdk deploy to 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 via pip will be updated, so I want it to re-build.

I found #8493 which claims that you can do this with cdk deploy --method direct, but this didn't work for me (nor did cdk deploy --force).

@buliverd53
Copy link

it's been two years without working :-(, no updates about this issue yet? it would be really nice to have this working again without doing any work-around

@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 23, 2023

Hi everyone on this issue,

Please run the command again with -v:

cdk deploy --force -v

And observe the additional logged output.

  • If the message says 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 --force to force it to update.
  • If you see the text 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 see neither of these messages, then let me know what messages you do see.

If you are planning to use --force to 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.

@AndyRubio
Copy link

Our workaround has been to deploy the last version, then redeploy the current version. Far from ideal.

rix0rrr added a commit that referenced this issue Nov 27, 2023
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.
mergify bot pushed a commit that referenced this issue Nov 27, 2023
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.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests