When calling terraform apply <plan file>, -state isn't supported:
Failed to load backend: State path cannot be specified with a plan file. The plan itself contains
the state to use. If you wish to change that, please create a new plan and specify the state path when creating the plan.
This is problematic in the event that the apply has a partial failure - this writes terraform.tfstate, and should instead create a backup for my existing state file and overwrite it.
Actually, even successful applies (from a plan file) are problematic:
Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path:
It shouldn't be necessary to manually move the terraform.tfstate file to the custom state location after every apply.
Hi,
This is a critical bug. If you use terraform for multiple environments and you can't specify different states files to save it is a completly mess... We have upgraded Terraform and now we are stucked. It used to work well before.
Why it is not solved yet?
Thanks,
Hi,
After reading #4725 we have solved the problem specifing -state-out parameter instead of -state in terraform apply
Best,
I am going to close this issue as you have already reported the solution: the parameter is -state-out instead of state
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.
Most helpful comment
Actually, even successful applies (from a plan file) are problematic:
It shouldn't be necessary to manually move the
terraform.tfstatefile to the custom state location after every apply.