The object 'vim.Folder:group-v54745' has already been deleted or has not been completely created

Hey guys so im just starting out on terraform and im trying to implement this within our company infrastructure, for use with vsphere.

I ran a test with the following bit of syntax and everything went well, it did what i expected it to do, it created a folder within the correct data center:

data "vsphere_datacenter" "dc" {
    name = "LON01"
}

resource "vsphere_folder" "instance" {
    datacenter_id = "${data.vsphere_datacenter.dc.id}"
    path = "test"
    type = "vm"
}

unfortunately i deleted the folder within the vsphere gui not using terraform destroy. Now whenever i run the same bit of syntax, i get the following error:

vsphere_folder.folder: Refreshing state… [id=group-v54745]

Error: cannot locate folder: ServerFaultCode: The object 'vim.Folder:group-v54745' has already been deleted or has not been completely created

how do i go about fixing this? ive read the terraform documentation and couldnt find anything, i looked in different forums and nothing. I then started playing around with the resource part of the script, by adding different values, and also the data segment of the script but no joy.

any help is a blessing.

many thanks
D

Ok so i figured it out, so i guess this is pretty much similar to all the other “been deleted or has not been completely created” issues out there.

The simple answer is to delete the terraform.tfstate file.

seems like re-running the script doesnt overwrite this state file, so manually editing or deleting it will do the trick.