0

I defined remote backend for managing tfstate with Swift.

terraform {
  backend "swift" {
    container = "example"
  }
}

After I run "terraform init", I get following error sometimes:

Do you want to copy existing state to the new backend?
Pre-existing state was found while migrating the previous "swift" backend to the
newly configured "swift" backend. An existing non-empty state already exists in
the new backend. The two states have been saved to temporary files that will be
removed after responding to this query.

Previous (type "swift"): /tmp/terraform704677678/1-swift.tfstate
New      (type "swift"): /tmp/terraform704677678/2-swift.tfstate

Do you want to overwrite the state in the new backend with the previous state?
Enter "yes" to copy and "no" to start with the existing state in the newly
configured "swift" backend.

Enter a value:

This really makes hard to automate running Terraform because of unexpected input required.

I need Ansible to operate only with remote tfstate saved in container and no local files.

After terraform init task is finished, there is no /tmp/terraform*.

Thanks in advance for help.

0

Looks like you're working with two state files. If you're sure it's trying to use the correct one now, you can say yes and have it copy the old state to the new, then this error won't show up again.

  • No matter "yes" or "no" answer, it will appear randomly again. – dannyx May 28 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.