Terraformer — Reverse-Engineer Existing Cloud Infrastructure to Terraform
Terraformer is a CLI tool by Google that reads live cloud resources from AWS, GCP, Azure, and 30+ other providers and generates corresponding Terraform HCL files and state, enabling infrastructure-as-code adoption on brownfield environments.
What it is
Terraformer is a CLI tool originally developed at Google that reads existing cloud infrastructure and generates corresponding Terraform HCL configuration files and state files. It supports AWS, GCP, Azure, and over 30 additional providers. The primary use case is adopting infrastructure-as-code on brownfield environments where cloud resources were created manually or through other tools.
Terraformer targets DevOps engineers and platform teams who need to bring existing cloud infrastructure under Terraform management without manually writing HCL for every resource.
How it saves time or tokens
Manually writing Terraform configurations for existing infrastructure is tedious and error-prone. A typical AWS account might have hundreds of resources across VPCs, security groups, EC2 instances, RDS databases, and IAM policies. Terraformer scans all resources for a given provider and service, then generates the HCL files and imports the state in one command. This turns weeks of manual work into minutes.
For AI-assisted infrastructure management, Terraformer's output provides a machine-readable snapshot of your cloud infrastructure that an LLM can analyze for cost optimization, security review, or architecture documentation.
How to use
- Install Terraformer: download the binary from GitHub releases or use
brew install terraformeron macOS. - Ensure you have the corresponding Terraform provider installed and valid cloud credentials configured (AWS CLI, gcloud, etc.).
- Run Terraformer to import resources:
terraformer import aws --resources=vpc,subnet,sg --regions=us-east-1. The generated HCL and state files appear in agenerated/directory.
Example
# Import all AWS VPC resources in us-east-1
terraformer import aws \
--resources=vpc,subnet,security_group,route_table \
--regions=us-east-1 \
--profile=production
# Output structure:
# generated/
# aws/
# vpc/
# vpc.tf
# terraform.tfstate
# subnet/
# subnet.tf
# terraform.tfstate
Each resource type gets its own directory with the generated HCL and a corresponding state file.
Related on TokRepo
- DevOps tools — Infrastructure and deployment tools
- Automation tools — Infrastructure automation solutions
Common pitfalls
- Terraformer generates one state file per resource type. You likely need to reorganize the generated code and merge state files into your team's existing Terraform structure.
- Generated HCL uses hard-coded IDs and ARNs. You should refactor the output to use variables, data sources, and module references for maintainable code.
- Some resource types have complex dependencies that Terraformer may not fully capture. Review the generated code for missing cross-references between resources.
Frequently Asked Questions
Terraformer supports AWS, GCP, Azure, Kubernetes, GitHub, Datadog, Cloudflare, and over 30 other providers. Each provider has its own set of importable resource types. Check the Terraformer README for the full list.
No. Terraformer is read-only. It queries cloud APIs to discover resources and generates Terraform files locally. It never creates, modifies, or deletes any cloud resources.
Yes. Use --resources=* to import all supported resource types for a provider. However, this can be slow for large accounts and may generate a large amount of code. Start with specific resource types you want to manage first.
After Terraformer generates the HCL and state, you typically refactor the code into your existing module structure, replace hard-coded values with variables, and use terraform state mv to merge state files into your workspace.
Terraformer is a Google-initiated open-source project. Community contributions continue, though some provider support may lag behind the latest Terraform provider versions. Check the repository for recent activity on your specific provider.
Citations (3)
- Terraformer GitHub— Terraformer generates Terraform from existing cloud infrastructure
- Terraformer README— Supports AWS, GCP, Azure, and 30+ providers
- Terraform Documentation— Terraform infrastructure as code
Related on TokRepo
Discussion
Related Assets
Moodle — Open-Source Learning Management System
The most widely used open-source learning platform, providing course management, assessments, and collaboration tools for educators and organizations worldwide.
Sylius — Headless E-Commerce Framework on Symfony
An open-source headless e-commerce platform built on Symfony and API Platform, designed for developers who need a customizable and API-first commerce solution.
Akaunting — Free Self-Hosted Accounting Software
A free, open-source online accounting application built on Laravel for small businesses and freelancers to manage invoices, expenses, and financial reports.