Error creating Network: googleapi: Error 409: The resource RESOURCE_NAME already exists
Terraform State
If you are using Terraform to create resources, do NOT modify them outside of Terraform.
Also it is not good idea deleting state from you project folder. You will not be able to “refetch” or “update” the state.
Terraform is declarative and not dynamic.
It is also good idea o store the state somewhere and .git is not good place, you should rather use backend.
Issue
Any way if you are stuck with:
Error creating Network: googleapi: Error 409: The resource RESOURCE_NAME already exists
Solution
You can try fix it in this order (from least invasive to complete deletion of your infrastructure)
Do terraform apply
after each step:
- Try to refresh
terraform refresh
- Try to taint broken resource
terraform taint RESOURCE_NAME
- Try to replace broken resource
terraform replace RESOURCE_NAME
- Manually go to your cloud provider and delete the resource, then recreate from terraform