We upgraded terraform version and we have a problem with terraform remote state. Basiacaly I run this command to update azurerm provider:
terraform state replace-provider ' ' Right now when I run plan command it shows me some errors. All are the same but resource if different. For example:
To work with module.name.module.lb_name.azurerm_lb_probe.instance its original provider configuration at provider[""] is required, but it has been removed. This occurs when a provider configuration is removed while objects created by that provider still exist in the state. Re-add the provider configuration to destroy module.name.module.lb_name.azurerm_lb_probe.instance, after which you can remove the provider configuration again. Basically the state was updated and the provider looks like this:
"provider": "provider.azurerm" but it should look like this:
"provider": "provider[\""]" Is there any way to update it via terraform commands or the only way to fix it is to edit state file manually?
51 Answer
When you replace the providers for the Terraform upgrade with the command:
terraform state replace-provider ' ' OK, there is no problem. And then you can use the command below to check the current providers:
terraform providers The screenshot will show like this:
At this time, the providers are the same as the requirement. Then you need to init again to pull the current providers to replace the existing ones with the command below:
terraform init This is the step you have missed.
