Terraform refresh

I have lost my terraform state files, I’ve tried to use refresh to get a new one but no luck .
Is it possible to somehow tell terraform to scan my current infrastructure and to recreate terraform state files ?

Hi @suppix,

Terraform uses the state to remember which objects in your remote system are managed by this particular Terraform configuration, so there is no automatic way to recover that information.

However, if you have defined your infrastructure in a systematic way such that you can recognize which remote objects belong to which resource instances in your configuration then you can potentially write your own small script to generate terraform import calls to re-associate the existing objects with your resources, and thus rebuild the information that was formerly recorded in your state snapshot.