# Terraform doesn't recognize resources after VM restore

**URL:** <https://discuss.hashicorp.com/t/terraform-doesnt-recognize-resources-after-vm-restore/55255>\
**Category:** Terraform\
**Created:** [June 21, 2023, 1:23pm UTC](https://discuss.hashicorp.com/t/terraform-doesnt-recognize-resources-after-vm-restore/55255 "2023-06-21T13:23:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![The-Judge](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/the-judge/32/24932_2.png) [@The-Judge](https://discuss.hashicorp.com/u/The-Judge)\
**Post date:** [June 21, 2023, 1:23pm UTC](https://discuss.hashicorp.com/t/terraform-doesnt-recognize-resources-after-vm-restore/55255/1 "2023-06-21T13:23:27Z")

</div>

Hi everyone,

I’m hitting a particular case in which I am not sure how to proceed:  
We use Terraform to manage VMs in a VMware vSphere-based datacenter.

Recently, there was an issue with some of those VMs we manage with Terraform, which resulted in the data center admins restoring the VMs from a Backup.  
The VMs are up and running again, but whenever we want to plan/apply our unchanged Terraform recipes now, Terraform does not recognize these VMs anymore and suggests creating new ones.  
Since other resources depend on these VMs, we can’t really skip these.

How to recover from that? How can we tell Terraform that the existing VM XYZ is the one from its statefile?

Best regards,  
Marc

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [June 21, 2023, 3:07pm UTC](https://discuss.hashicorp.com/t/terraform-doesnt-recognize-resources-after-vm-restore/55255/2 "2023-06-21T15:07:39Z")

</div>

You will need to use the `terraform state rm` command to have Terraform forget about the VMs that no longer exist, and the `terraform import` command to reassociate the restored VMs with the Terraform resource addresses that would otherwise be created.

Having done so, review `terraform plan` carefully to be certain everything is as expected before running an apply.
