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

**URL:** <https://discuss.hashicorp.com/t/can-terraform-auto-create-a-tf-file-by-pointing-it-to-an-aws-object/20353>\
**Category:** CDK for Terraform\
**Created:** [January 30, 2021, 5:04pm UTC](https://discuss.hashicorp.com/t/can-terraform-auto-create-a-tf-file-by-pointing-it-to-an-aws-object/20353 "2021-01-30T17:04:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smsinger3](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/smsinger3/32/16861_2.png) [@smsinger3](https://discuss.hashicorp.com/u/smsinger3)\
**Post date:** [January 30, 2021, 5:04pm UTC](https://discuss.hashicorp.com/t/can-terraform-auto-create-a-tf-file-by-pointing-it-to-an-aws-object/20353/1 "2021-01-30T17:04:24Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![skorfmann](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/skorfmann/32/9494_2.png) [@skorfmann](https://discuss.hashicorp.com/u/skorfmann)\
**Post date:** [January 30, 2021, 5:41pm UTC](https://discuss.hashicorp.com/t/can-terraform-auto-create-a-tf-file-by-pointing-it-to-an-aws-object/20353/2 "2021-01-30T17:41:34Z")

</div>

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](https://github.com/hashicorp/terraform-cdk/issues/35)

---

<div class="post-metadata">

**Author:** ![stuart-c](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/stuart-c/32/10789_2.png) [@stuart-c](https://discuss.hashicorp.com/u/stuart-c)\
**Post date:** [January 31, 2021, 10:29am UTC](https://discuss.hashicorp.com/t/can-terraform-auto-create-a-tf-file-by-pointing-it-to-an-aws-object/20353/3 "2021-01-31T10:29:21Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![skorfmann](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/skorfmann/32/9494_2.png) [@skorfmann](https://discuss.hashicorp.com/u/skorfmann)\
**Post date:** [February 5, 2021, 12:45pm UTC](https://discuss.hashicorp.com/t/can-terraform-auto-create-a-tf-file-by-pointing-it-to-an-aws-object/20353/4 "2021-02-05T12:45:27Z")

</div>

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