Imported resource - how to keep it intact in case of terraform destroy?


we have some AWS resources created before without Terraform.
To add some additional stuff I terraform import it and then developed TF code.
Now I would like to destroy all resources created by TF but keep the imported one intact.
How do I do that ?

Is terraform state rm ... an answer to this ?

Hi @przemolb, yes, state rm is how you would go about getting terraform to “forget” about a resource. Once the state is removed, terraform has no way to associate the configuration with the real resource you want to preserve.

1 Like