Destroying resources with state file only

I have terraform state file only, don’t have conf file which were used to create resources . How can I delete resources ? Is it possible to destroy resources without having conf files ?

To resolve this, I performed below steps -

  1. Copy .terraform folder from other projects which is having TF conf to my project directory
  2. Keep the state file in my project directory
  3. Created backed.tf to mention the local path of the state file.
  4. Then #terraform init
  5. Then run #terraform destroy,

Thanks for sharing what worked for you, @vasimjams!

I just want to confirm that a minimal configuration just to destroy objects recorded in a state snapshot must contain:

  • A suitable backend configuration referring to the state.
  • Provider configurations for any providers that the resources in the state refer to. (For some providers, they can infer the necessary information automatically from the environment if you have suitable credentials/etc configured there, but that’s not true for all providers.)

Depending on how the original configuration was designed, you might also need:

  • Configuration for destroy-time provisioners and their associated connection blocks, if the system was relying on Terraform to take some special action at destroy time.
  • module blocks for any modules that themselves contained provider configurations, so that Terraform can then find the provider configurations in those modules. (We don’t recommend using provider configurations in nested modules because of this problem, but Terraform continues to support it for single-instance modules for backward compatibility only.)
  • Provider version constraints, if the state includes resources of types that are no longer supported by the latest version of the provider that created them, and thus the automatically-selected provider version would not know how to destroy the object.