When running terraform plan, you may get the error below:
Backend reinitialization required. Please run "terraform init".
Reason: Initial configuration of the requested backend "azurerm"
The "backend" is the interface that Terraform uses to store state,e,
perform operations, etc. If this message is showing up, it means that theshowing up, it means that the
Terraform configuration you're using is using a custom configuration forthe Terraform backend.
Changes to backend configurations require reinitialization. This allows
Terraform to setup the new configuration, copy existing state, etc. This isonly done during "terraform init". Please run that command now then try again.
If the change reason above is incorrect, please verify your configuration
hasn't changed and try again. At this point, no changes to your existingconfiguration or state have been made.
Failed to load backend: Initialization required. Please see the error message above.
I found that the cause of the problem was that I had used the backend block in my terraform configuration like below:
This tells terraform to expect some backend configuration however I was just testing and running terraform init without specifying a backend like below:
terraform init -input=false -backend=false
The solution is pretty simple. Basically, you need to either remove the backend settings from your terraform block but that's not the way you want to go if you want to use remote state. The other option is to specify backend settings when you run terraform init, like this:
terraform init \
You should now be able to run terraform plan.