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 service account googleapi Error 409
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:

  1. Try to refresh terraform refresh
  2. Try to taint broken resource terraform taint RESOURCE_NAME
  3. Try to replace broken resource terraform replace RESOURCE_NAME
  4. Manually go to your cloud provider and delete the resource, then recreate from terraform

Buy me a coffeeOut of coffee 😱, please help!