Can Terraform auto create a tf file by pointing it to an AWS object?

I’m new to Terraform, so this may be a basic question. Is it possible to run a command and point it directly to a resource and get the .tf file output? Another way to think about it is to export a specific resource into a .tf file. I’m thinking of this from basically a starting point to build a proper terraform project with variables and modules. Copying a tf file like like to each environment I’m sure violates many best practices. Thanks!

That’s an interesting use case. However, we don’t support rendering a single resource only at the moment. Do you have a more specific example of what you’re trying to achieve?

What I’m wondering: would this be helpful in your case (since you’re apparently dealing with multiple stages)? Handling of Multiple Stacks · Issue #35 · hashicorp/terraform-cdk · GitHub

The terraforming tool might be what you are looking for: GitHub - dtan4/terraforming: Export existing AWS resources to Terraform style (tf, tfstate)

It is pretty old, but it will probably still work to some extent, and there appear to be a lot of updated forks…

Right, there’s another one which does something similar GitHub - iann0036/former2: Generate CloudFormation / Terraform / Troposphere templates from your existing AWS resources.