Terraform v0.12.0
terraform {
required_version = "= 0.12.0"
backend "gcs" {
#project = "foo"
bucket = "foo"
prefix = "foo"
}
}
$ terraform init
Initializing the backend...
Backend configuration changed!
Terraform has detected that the configuration specified for the backend
has changed. Terraform will now check for existing state in the backends.
Error: "project": [REMOVED] Please remove this attribute. It is not used since the backend no longer creates the bucket if it does not yet exist
terraform init should give user clear information about what needs to be done to proceed with migration in this case. It should suggest removing project parameter from gsc backend and running with -reconfigure flag.
Terraform init fails and instruction how to proceed is unclear.
main.tf with following content:terraform {
required_version = "= 0.11.14"
backend "gcs" {
project = "foo"
bucket = "foo"
prefix = "foo"
}
}
terraform init
0.12.0:terraform 0.12upgrade
versions.tf and modify main.tf to have required_version = "= 0.12.0" linerm versions.tf
sed -i 's/0.11.14/0.12.0/g' main.tf
terraform init with Terraform 0.12.0terraform init
I've tried migrating my existing project from 0.11.4 to 0.12.0. When I run terraform init for the first time, it complained, that project parameter has been removed, however, it does not tell which project parameter exactly has been removed.
Anyway, from source, I found that this is a change in gsc backend, so I commented out the parameter, however Terraform was still complaining.
It seems that workaround for this issue is to run:
terraform init -reconfigure
which Terraform suggested me when I removed both region and project parameters from Terraform source.
EDIT: I moved the workaround to separated section, so it's easier to find for people affected by this.
any updates here?
I did what was suggested here to work around the problem (running with -reconfigure) and I guess it completely overwrote my state, as "terraform plan" now shows that it's going to try to create all of my resources again. I guess I'll have to go re-import them back into the new state. This is very much still broken, since the normal commands do not recognize when you update your config, resulting in dramatic actions, like -reconfigure, which is clearly also undesirable. Luckily I only had 22 resources
Any updates here? As I understand, terraform init -reconfigure will rewrite state completely. But do I always need to re-import all my resources again as @moonkid196 had to do?
FYI, we ran into this when upgrading from 0.11.3 to 0.12.8, and were able to work past it by doing the following:
project attribute from the backend and terraform_remote_state declarationsterraform init --upgradeError: Failed to load state: Decoding state file version failed: invalid character '}' looking for beginning of object key string. This was resolved by deleting (DON'T DO THIS if your state is local, we use remote state) the .terraform folder in the project directory and re-running terraform init --upgrade. Also, in an earlier version of this comment I mentioned editing the remote state file to remove the project attribute from the remote state resource declaration. I did do this on the first project we converted but I am not sure it was necessary. I didn't have to do it for the three I converted the next day. If you do the above and are still having problems it's worth a shot.
I managed to get this working by just removing the .terraform folder. 0.11.14 to 0.12.8 upgrade.
Fixed it by removing the backend.config.project property from the .terraform/terraform.tfstate file
I'm experiencing the same behavior, I'm using v0.12.21. If I run with v0.11.14 it works. I tried any fix suggested above without any luck.
I am going to close this as a stale issue. If you are still experiencing a problem with terraform v0.13, please open a new one!
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.
Most helpful comment
Fixed it by removing the backend.config.project property from the .terraform/terraform.tfstate file