Terraform: Init force-copy is not "equivalent to providing a "yes" to all confirmation prompts."

Created on 21 Mar 2018  ·  9Comments  ·  Source: hashicorp/terraform

The setting force-copy in terraform init is not 'equivalent to providing a "yes" to all confirmation prompts.'

Terraform Version

Terraform v0.11.3

Steps to Reproduce

  1. Start with a terraform recipe without a backend.
  2. Run apply.
  3. Configure a new backend (consul in my case).
  4. Run terraform init -force-copy

Expected Behavior

Terraform should copy the state to consul without user interaction.

Actual Behavior

Initializing modules...

Initializing the backend...
Do you want to migrate all workspaces to "consul"?
  Both the existing "local" backend and the newly configured "consul" backend support
  workspaces. When migrating between backends, Terraform will copy all
  workspaces (with the same names). THIS WILL OVERWRITE any conflicting
  states in the destination.

  Terraform initialization doesn't currently migrate only select workspaces.
  If you want to migrate a select number of workspaces, you must manually
  pull and push those states.

  If you answer "yes", Terraform will migrate all states. If you answer
  "no", Terraform will abort.

  Enter a value: 

Additional Context

The following alternatives were tried:

  1. terraform init -reconfigure -force-copy same outcome as without the reconfigure.
  2. terraform init -input=false -reconfigure and terraform init -input=false -reconfigure -force-copy with the outcome Error asking for state migration action: input is disabled.
bug cli v0.11 waiting-response

Most helpful comment

Hi folks,

The terraform core team is heads-down on the terraform 0.12 release, which is currently feature-frozen. I see that there is already PR open and we will review it once 0.12 is released.

In general, the best way to influence our prioritization is by reacting to the original issue comment with 👍, which we can and do report on during prioritization.

All 9 comments

The obvious workaround is echo "yes" | terraform init.

This bug is especially annoying when TF_INPUT="false" in CI environments. For those cases:

echo "yes" | TF_INPUT="true" terraform

Is there any update on this? We are getting "Error asking for state migration action: input is disabled" even if -force-copy option. Our command :

terraform init -input=false -force-copy -backend-config=config_file @vaibhav-si

Any update on this @jbardin

Hey I am also having this same issue. Any update on this?

Hi folks,

The terraform core team is heads-down on the terraform 0.12 release, which is currently feature-frozen. I see that there is already PR open and we will review it once 0.12 is released.

In general, the best way to influence our prioritization is by reacting to the original issue comment with 👍, which we can and do report on during prioritization.

This is still affecting v0.12

@jeffmccollum @Lasering and other folks who have upvoted this: I have tried to reproduce this on 0.12.26 with Terraform Cloud ("remote" backend) and AWS S3, and in my tests when I ran init -force-copy it copied state without prompting me.

I have put together a scripted issue reproduction in https://github.com/danieldreier/terraform-issue-reproductions/tree/master/17663 to help us collaborate on this. Based on my initial attempts to reproduce it, it looks to me like this was resolved at some point, but given how many people have upvoted this, I would appreciate some help and confirmation. I know it's possible I've scripted this wrong.

If you are still seeing this behavior on 0.12.26 or an 0.13.0 beta, please make a PR against that reproduction case to show me how to trigger this behavior.

I am going to close this issue due to both inactivity and the fact that it appears to be resolved, thanks!

If there is still a question, I recommend the the community forum, where there are far more people available to help. If there is a bug or you would like to make a feature request, please open a new issue and fill out the template.
Thanks!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zeninfinity picture zeninfinity  ·  3Comments

carl-youngblood picture carl-youngblood  ·  3Comments

ketzacoatl picture ketzacoatl  ·  3Comments

rjinski picture rjinski  ·  3Comments

rjinski picture rjinski  ·  3Comments