# How do I "export" my manually configure infrastructure into IaC

**URL:** <https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262>\
**Category:** Architecture & IaC\
**Tags:** cloudformation\
**Created:** [July 5, 2025, 12:46pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262 "2025-07-05T12:46:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnCap79](https://awshq.com/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@AnCap79](https://awshq.com/u/AnCap79)\
**Post date:** [July 5, 2025, 12:46pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/1 "2025-07-05T12:46:10Z")

</div>

Single developer, sole founder here working on an MVP. I made the decision during planning the system architecture to NOT go with IaC (CloudFormation, AWS Serverless Application Model) early on and use the GUI to configure my infrastructure. Reasoning was to reduce complexity and increase development speed. I used SAM on a previous project and while it was great when it worked, I spent a lot of time writing template code instead of application code (the code that’s most necessary to get the product to market).

I’m always thinking ahead and I was reading posts here that people really liked Terraform. I’ve never used it but it got me thinking more about my IaC decision.

My question for feedback is simply, how easy is it to transform my manually configured infrastructure into IaC code? Who here has done it and what was your experience (e.g. how, success/failure, lessons learned)?

* * *

**Related discussions:**

- [For those doing AWS consulting, how do you find clients?](https://awshq.com/t/for-those-doing-aws-consulting-how-do-you-find-clients/21341)
- [Build CI/CD for IAC](https://awshq.com/t/build-ci-cd-for-iac/19927)
- [Why does AWS have so many deployment tools?](https://awshq.com/t/why-does-aws-have-so-many-deployment-tools/20482)
- [Drift-aware change sets were a great idea, but why does it want to update anything using !ImportValue?](https://awshq.com/t/drift-aware-change-sets-were-a-great-idea-but-why-does-it-want-to-update-anything-using-importvalue/20965)
- [Benefit of Cloudformation over CDK?](https://awshq.com/t/benefit-of-cloudformation-over-cdk/17450)

---

<div class="post-metadata">

**Author:** ![tails142](https://awshq.com/letter_avatar_proxy/v4/letter/t/b3f665/32.png) [@tails142](https://awshq.com/u/tails142)\
**Post date:** [July 5, 2025, 12:49pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/2 "2025-07-05T12:49:59Z")

</div>

Terraform import is a command and there’s also the terraformer tool

---

<div class="post-metadata">

**Author:** ![Traveller\_47](https://awshq.com/letter_avatar_proxy/v4/letter/t/85f322/32.png) [@Traveller\_47](https://awshq.com/u/Traveller_47)\
**Post date:** [July 5, 2025, 12:54pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/3 "2025-07-05T12:54:45Z")

</div>

For Terraform you use import block  
You have to add the resources ids manually nevertheless its more accurate than other approaches

[https://developer.hashicorp.com/terraform/language/import](https://developer.hashicorp.com/terraform/language/import) no but

---

<div class="post-metadata">

**Author:** ![dghah](https://awshq.com/letter_avatar_proxy/v4/letter/d/f6c823/32.png) [@dghah](https://awshq.com/u/dghah)\
**Post date:** [July 5, 2025, 12:57pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/4 "2025-07-05T12:57:39Z")

</div>

My lesson learned:

Just start fresh and clean with terraform using your click ops built mvp as the model. Use terraform to recreate each resource type and take the time to understand things and add improvements like consistent tagging or whatever.

If you are new to terraform this is gonna be better than starting with a massive import or trying to punt on the hard work by letting some transformation or conversion engine make decisions for you that you don’t understand until well down the learning curve road at which point it may be hard to alter to ,wet your actual future needs

---

<div class="post-metadata">

**Author:** ![vshanko](https://awshq.com/letter_avatar_proxy/v4/letter/v/8edcca/32.png) [@vshanko](https://awshq.com/u/vshanko)\
**Post date:** [July 5, 2025, 1:00pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/5 "2025-07-05T13:00:52Z")

</div>

You can use terraformer: [https://github.com/GoogleCloudPlatform/terraformer](https://github.com/GoogleCloudPlatform/terraformer)

---

<div class="post-metadata">

**Author:** ![enjoytheshow](https://awshq.com/letter_avatar_proxy/v4/letter/e/87869e/32.png) [@enjoytheshow](https://awshq.com/u/enjoytheshow)\
**Post date:** [July 5, 2025, 1:07pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/6 "2025-07-05T13:07:21Z")

</div>

Honestly might be an unpopular opinion here because if GenAI hate but I did this recently and it worked shockingly well — use a CLI tool like Claude AI and give it permission to use a read only role on the AWS CLI. Let it come up with a skeleton infra as code based on what actually exists in the account. It helps if you can prompt it with what actual services you used.

---

<div class="post-metadata">

**Author:** ![cunninglingers](https://awshq.com/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@cunninglingers](https://awshq.com/u/cunninglingers)\
**Post date:** [July 5, 2025, 1:07pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/7 "2025-07-05T13:07:50Z")

</div>

Look at Cloudformation/CDK import if you want an AWS-specific solution

---

<div class="post-metadata">

**Author:** ![case\_O\_The\_Mondays](https://awshq.com/letter_avatar_proxy/v4/letter/c/87869e/32.png) [@case\_O\_The\_Mondays](https://awshq.com/u/case_O_The_Mondays)\
**Post date:** [July 5, 2025, 1:09pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/8 "2025-07-05T13:09:41Z")

</div>

Some parts are easy, but the journey to doing this is not straightforward. If you are in a position to simply re-create your resources using IaC from the start, that is a much easier task, frankly.

I use tofo, but the commands are the same for terraform, so I’m just referring to the tool as “tf” below.

The rinse-and-repeat cycle that’s worked for me is:

- Identify a resource that you want to codify
- Starting with the major components of the resource, create your HCL code describing the resource.
- Use tf import to import the unmanaged resource you described into your state
- Run tf plan to see if you missed anything
- Repeat these steps until you have completely managed all aspects of the resource

There are tools like terraformer that can help translating existing resources into HCL, but in my experience these are just shortcuts to the cycle I described above, and you still want to format your code and split it up based on your deployment lifecycle.

Both tofu and terraform also have an option to generate HCL from existing resources. It’s experimental, but decent: [https://opentofu.org/docs/language/import/generating-configuration/](https://opentofu.org/docs/language/import/generating-configuration/)

Here’s a good starter article on using tf import: [https://spacelift.io/blog/importing-exisiting-infrastructure-into-terraform](https://spacelift.io/blog/importing-exisiting-infrastructure-into-terraform)

---

<div class="post-metadata">

**Author:** ![pixeladdie](https://awshq.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@pixeladdie](https://awshq.com/u/pixeladdie)\
**Post date:** [July 5, 2025, 1:18pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/9 "2025-07-05T13:18:30Z")

</div>

IaC generator [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html)

---

<div class="post-metadata">

**Author:** ![brikis98](https://awshq.com/letter_avatar_proxy/v4/letter/b/4af34b/32.png) [@brikis98](https://awshq.com/u/brikis98)\
**Post date:** [July 5, 2025, 1:23pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/10 "2025-07-05T13:23:34Z")

</div>

There are four primary options:

1. **Write Terraform code, then use `import` blocks**. Write your Terraform code, and then add [`import` blocks](https://developer.hashicorp.com/terraform/language/import) to import the existing infrastructure into the state file, so you can manage that infrastructure as code. This lets you write the code exactly as you want, but it is tedious and time consuming, as you typically need _many_ `import` blocks, and it takes a while to look up all those IDs manually.

2. **Use `import` blocks to generate code**. In this approach, you add a bunch of `import` blocks and you run `terraform plan -generate-config-out=PATH` to [generate the corresponding Terraform configuration](https://developer.hashicorp.com/terraform/language/import/generating-configuration) for the imported resources. This saves you time on writing the Terraform code, but you still have to create all the `import` blocks manually, and the Terraform code you get back might not be organized the way you would’ve done it from scratch.

3. **Use Terraformer to generate code**. In this approach, you use the open source tool [Terraformer](https://github.com/GoogleCloudPlatform/terraformer) to read the data from your cloud account and generate the Terraform code for the resources it finds. You can have it create code for all resources it finds or just a subset. This saves you time in that you don’t have to write code or `import` blocks, but again, the generated code is not likely to be written the way you would’ve done it yourself.

4. **Write Terraform code, and use it to deploy new infrastructure**. In this approach, you write Terraform code, and run `apply` to deploy a completely new set of infrastructure. You then manually undeploy your existing infrastructure. The advantage here is that this lets you write the code exactly as you want, gives you a clean deployment (typically, the original, manual deployment is quite messy and you want to change stuff anyway), and you don’t have to spend time tediously trying to `import` existing stuff.

The option I’ve seen used the most, and the one that seems to work the best, is a combination of (4) and (1). That is, you write Terraform code and use it to deploy new infrastructure for _most_ things, and you add `import` blocks just for the handful of resources that you can’t deploy from scratch (e.g., an RDS DB that has real data in it you don’t want to lose).

---

<div class="post-metadata">

**Author:** ![thomhj](https://awshq.com/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@thomhj](https://awshq.com/u/thomhj)\
**Post date:** [July 5, 2025, 1:45pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/11 "2025-07-05T13:45:08Z")

</div>

It really depends on the complexity of the resources but importing into [CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/import-resources.html) or [Terraform](https://developer.hashicorp.com/terraform/cli/import) is relatively simple.

I personally prefer terraform over cloudformation but it’s dealer’s choice. If you’re going to stay in only AWS then staying with CloudFormation is fine.

---

<div class="post-metadata">

**Author:** ![disgruntledg04t](https://awshq.com/letter_avatar_proxy/v4/letter/d/51bf81/32.png) [@disgruntledg04t](https://awshq.com/u/disgruntledg04t)\
**Post date:** [July 5, 2025, 1:55pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/12 "2025-07-05T13:55:34Z")

</div>

> [@dghah](#):
>
> My lesson learned: Just start fresh and clean with terraform using your click ops built mvp as the model. Use terraform to recreate each resource type and take the time to understand things and add improvements like …

ew no, just use `tf import`.

---

<div class="post-metadata">

**Author:** ![ninerniner49er](https://awshq.com/letter_avatar_proxy/v4/letter/n/85e7bf/32.png) [@ninerniner49er](https://awshq.com/u/ninerniner49er)\
**Post date:** [July 5, 2025, 2:01pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/13 "2025-07-05T14:01:22Z")

</div>

I’ve used this project to generate terraform projects. Can import most things in the aws account and get you started.

[https://github.com/cycloidio/terracognita](https://github.com/cycloidio/terracognita) GitHub - cycloidio/terracognita: Reads from existing public and private cloud providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration

---

<div class="post-metadata">

**Author:** ![aqyno](https://awshq.com/letter_avatar_proxy/v4/letter/a/c0e974/32.png) [@aqyno](https://awshq.com/u/aqyno)\
**Post date:** [July 5, 2025, 2:16pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/14 "2025-07-05T14:16:32Z")

</div>

Use [IaC generator](IaC generator [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html)). Then use Visual Studio Q integration to ask questions about the code, improve, explain thoroughly and even ask Q to transform to terraform. Deploy clean in another account preferably.

---

<div class="post-metadata">

**Author:** ![JagerAntlerite7](https://awshq.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@JagerAntlerite7](https://awshq.com/u/JagerAntlerite7)\
**Post date:** [July 5, 2025, 2:18pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/15 "2025-07-05T14:18:21Z")

</div>

Learn some type of IaC. Eventually you will need it for consistency and scale. This has been my experience with… pretty much everything.

---

<div class="post-metadata">

**Author:** ![DeathMetalDave](https://awshq.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@DeathMetalDave](https://awshq.com/u/DeathMetalDave)\
**Post date:** [July 5, 2025, 2:18pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/16 "2025-07-05T14:18:54Z")

</div>

> [@disgruntledg04t](#):
>
> ew no, just use `tf import`.

Second this. It took about a year for us to fully import 5 environments into terraform but it was worth it.

Some resources can’t be imported (target group attachment comes to mind) but it’s otherwise painless. Write the terraform you expect, import the resource, let it determine and apply differences.

---

<div class="post-metadata">

**Author:** ![CSYVR](https://awshq.com/letter_avatar_proxy/v4/letter/c/f475e1/32.png) [@CSYVR](https://awshq.com/u/CSYVR)\
**Post date:** [July 5, 2025, 2:26pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/17 "2025-07-05T14:26:06Z")

</div>

Cloudformation(CDK) import: don’t spend any time, maybe if it’s a single resource. Redeploy and migrate

Terraform: I have good experience using data sources and file generation to create the resources and import statements. Only works for many of the same resource type

My experience (and I’ve done dozens of these): Import stateful resources like S3 buckets, databases and networking. Redeploy stateless things like ECS tasks, roles and security groups.

---

<div class="post-metadata">

**Author:** ![Nearby-Middle-8991](https://awshq.com/letter_avatar_proxy/v4/letter/n/e19b73/32.png) [@Nearby-Middle-8991](https://awshq.com/u/Nearby-Middle-8991)\
**Post date:** [July 5, 2025, 2:27pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/18 "2025-07-05T14:27:10Z")

</div>

As someone who has been there in the past, one possible caveat:

ClickOps does _more_ than IaC. For instance, the first time you use a service via click ops, the interface creates service-linked roles and fixes various configurations, which doesn’t happen if you start straight out in IaC.

So if you start with clickops, then move to IaC, same account, it works. But then you go into a DR, or expansion, and try to use the IaC again on a fresh account, and it all fails… That’s why.

---

<div class="post-metadata">

**Author:** ![SikhGamer](https://awshq.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SikhGamer](https://awshq.com/u/SikhGamer)\
**Post date:** [July 5, 2025, 2:32pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/19 "2025-07-05T14:32:59Z")

</div>

Slow, laborious process of manual importing with the import block in Terraform. It’s tedious and boring but worth it.

---

<div class="post-metadata">

**Author:** ![MavZA](https://awshq.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@MavZA](https://awshq.com/u/MavZA)\
**Post date:** [July 5, 2025, 3:40pm UTC](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262/20 "2025-07-05T15:40:45Z")

</div>

There’s ways on TF and CloudFormation to import them into a state that you can then move forward with. Just make sure you persist the state and keep it safe and you’ll be golden 🙌🏻 there’s already some great suggestions in this thread. I just wanted to make sure to mention you need to keep your state safe if this is your first time on IaC.

[Next page](https://awshq.com/t/how-do-i-export-my-manually-configure-infrastructure-into-iac/20262.md?page=2)
