Home > Net >  Terraform error on creation azure virtual machine and other services
Terraform error on creation azure virtual machine and other services

Time:10-27

Team, I am new to terraform, and my requirement will be needed to create a resource group along with virtual machine. I made everything correctly, but not sure why my terraform is referring another state file which is not at all there in my subscription.[![enter image description here.enter image description here

  1. Show hidden folders ls -A
  2. Got ". terraform" folder cd .terraform
  3. Open and update the state file named "terraform.tfstate". Hope this resolve your issue.

CodePudding user response:

Looking at your image seems that you are using the sample code from the documentation to persist tf state on azurerm backend. Try changing the “key” value introducing something that recalls to your “project” and change it on other projects. In this way the state will be unique for projects

In my case i use this format .environment.tfstate Where environment can be dev, test, prod…

Alternatively you can use different container for projects and remove it from the key

  • Related