[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-81702":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":13,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":15,"starSnapshotCount":15,"syncStatus":17,"lastSyncTime":32,"discoverSource":33},81702,"tfimport","coolapso\u002Ftfimport","coolapso","Automatically import infrastructure to tfstate","https:\u002F\u002Ftfimport.coolapso.sh",null,"Go",49,3,45,0,1,2,4,1.81,"Other",false,"main",[24,25,26,27,28],"automation","cli","iac","opentofu","terraform","2026-06-12 02:04:18","# tfimport 🚀\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"tfimport_nobg.png\" alt=\"tfimport gopher mascot\" width=\"300\" \u002F>\n\u003C\u002Fp>\n\n`tfimport` is a Go-based CLI auto-pilot designed to automate the painful process of importing existing infrastructure into a Terraform or OpenTofu state file. \n\nInstead of manually hunting down the correct `terraform import` string format for every single resource (Is it an ARN? A VPC ID? A namespace\u002Fname combo?), you simply write the code that matches your existing infrastructure, generate a plan, and let `tfimport` figure out the rest.\n\n## ✨ Features\n\n- **Multi-Tool Support**: Works seamlessly with `terraform`, `terragrunt`, and `tofu`.\n- **Smart ID Deduction**: Understands the provider-specific import formats for hundreds of resources (e.g., AWS, Kubernetes).\n- **Offline Capable**: Can parse an existing `terraform show -json` plan file without needing to re-run plans.\n- **SDK Lookups**: Uses cloud provider SDKs (like AWS SDK) to look up opaque IDs (like `vpc-xxxxx` or resolving `aws_iam_policy` ARNs from path prefixes) based on tags and attributes known at plan time.\n- **Resilient**: Gracefully skips newly created resources and handles rate limiting with built-in configurable delays.\n\n## 📦 Installation\n\n### Arch Linux (AUR)\nYou can install `tfimport` from the Arch User Repository using your favorite AUR helper (e.g., `yay`, `paru`):\n```bash\nyay -S tfimport-bin\n```\n\n### Debian-based \u002F Ubuntu\nGrab the latest `.deb` package from the [Releases](https:\u002F\u002Fgithub.com\u002Fcoolapso\u002Ftfimport\u002Freleases) page and install it:\n```bash\n# Example for amd64 architecture\nwget https:\u002F\u002Fgithub.com\u002Fcoolapso\u002Ftfimport\u002Freleases\u002Flatest\u002Fdownload\u002Ftfimport_\u003Cversion>_linux_amd64.deb\nsudo dpkg -i tfimport_\u003Cversion>_linux_amd64.deb\n```\n\n### RPM-based (RHEL, Fedora, CentOS)\nGrab the latest `.rpm` package from the [Releases](https:\u002F\u002Fgithub.com\u002Fcoolapso\u002Ftfimport\u002Freleases) page and install it:\n```bash\n# Example for amd64 architecture\nwget https:\u002F\u002Fgithub.com\u002Fcoolapso\u002Ftfimport\u002Freleases\u002Flatest\u002Fdownload\u002Ftfimport_\u003Cversion>_linux_amd64.rpm\nsudo rpm -i tfimport_\u003Cversion>_linux_amd64.rpm\n```\n\n### Go Install ( Linux \u002F macOS \u002F Windows )\nIf you have Go installed on your system, you can build and install it directly:\n```bash\n# Install the latest version\ngo install github.com\u002Fcoolapso\u002Ftfimport@latest\n\n# Or install a specific version\ngo install github.com\u002Fcoolapso\u002Ftfimport@v0.0.1\n```\n\n### Windows\nDownload the latest Windows `.zip` archive from the [Releases](https:\u002F\u002Fgithub.com\u002Fcoolapso\u002Ftfimport\u002Freleases) page. Extract the `tfimport.exe` binary and move it to a folder that is included in your system's `PATH`.\nAlternatively, you can build it from source using the `go install` method above.\n\n### Install Script (macOS \u002F Linux)\nYou can also use our convenient installation script that automatically detects your OS and architecture, and downloads the correct binary to `\u002Fusr\u002Flocal\u002Fbin`:\n```bash\ncurl -sL https:\u002F\u002Fraw.githubusercontent.com\u002Fcoolapso\u002Ftfimport\u002Fmain\u002Fdocs\u002Finstall.sh | sudo bash\n```\n*(An uninstall script is also available at `docs\u002Funinstall.sh`)*\n\n## 🛠 Usage\n\n1. Write your Terraform\u002FTerragrunt manifests to match the infrastructure that already exists in the cloud.\n2. Run `tfimport` and point it to your tool of choice!\n\n```bash\n# Using Terragrunt with an existing plan file\ntfimport --tg --plan-file .tfimport\u002Ftfplan\n\n# Using Terraform\ntfimport --terraform\n\n# Using OpenTofu (Default)\ntfimport\n```\n\n### Flags\n\n- `--tg`: Execute plan and import using Terragrunt.\n- `--terraform` \u002F `--tf`: Execute plan and import using Terraform.\n- `--plan-file \u003Cpath>`: Provide a path to an existing plan file to skip the planning phase.\n- `--dry-run`: Show import details, only used with `--run-import`.\n- `--ignore \u003Cpatterns>`: Comma-separated list of resource addresses or wildcards to ignore (e.g., `aws_iam_role.*`, `module.new_feature.*`). Can be set multiple times.\n- `--run-import`: Import resources directly via the CLI instead of generating an `import.tf` block file.\n- `--delay \u003Cduration>`: Set a delay between imports to avoid API rate limits and DNS exhaustion when using `--run-import` (e.g., `1s`, `5s`). Defaults to `2s`.\n\n---\n\n## ⚖️ Import Execution\n\nBy default, `tfimport` generates a static `import.tf` file containing HCL `import {}` blocks (available in Terraform 1.5+ and OpenTofu). You can opt out of this and run CLI imports sequentially by passing the `--run-import` flag.\n\n### 💡 Resilience & Smart Imports\n- **Graceful New Resource Handling:** If `tfimport` attempts to import a resource and the cloud provider returns a \"non-existent remote object\" error, it intelligently assumes this is a genuinely new resource you want to create (not import). It will gracefully skip it and continue without penalizing you with error timeouts.\n- **SDK Lookups:** Uses cloud provider SDKs (like AWS SDK) to look up opaque IDs (like `vpc-xxxxx` or IAM Policy ARNs based on `name_prefix`) using attributes known at plan time.\n\n## 💻 For Developers\n\n`tfimport` is designed to be highly extensible. The core logic (`cmd\u002Froot.go`) is completely decoupled from the provider-specific logic. \n\nAll ID deduction logic lives in the `internal\u002Fproviders\u002F` package. The CLI simply passes the resource type and configuration to `providers.GetImportID(ctx, resourceType, config)`.\n\n### Adding Support for New Providers (🛑 READ THIS FIRST)\n\nTerraform providers (like Azure, GCP, or even AWS) have *hundreds* to *thousands* of resources. Each resource has its own specific string format required for the `terraform import` command.\n\n**DO NOT DO THIS MANUALLY.** It is incredibly tedious and error-prone. \n\nInstead, we strongly recommend using an **AI Agent** (like Copilot, Cursor, or Claude) to bootstrap new providers. We have built a specialized workflow for this:\n\n1. **Read the AI Guide:** Check out [`AGENTS.md`](AGENTS.md) in the root of the project. This file contains precise instructions for AI agents on how this project is structured.\n2. **The Doc Cruncher Trick:** Inside the `scripts\u002F` directory, there is a `doc_cruncher.go` script. You (or your AI agent) can clone the official HashiCorp provider documentation repository (e.g., `terraform-provider-google`) and run the script against the markdown files. The script uses Regex to parse the \"Import\" sections of the official documentation and automatically generates the entire Go switch statement for thousands of resources in seconds!\n3. **Custom Resolvers:** Not all IDs can be statically generated. Some require querying the cloud API (e.g., looking up a VPC ID by its Name tag). For this, the system supports \"Custom Resolvers\" (e.g., `internal\u002Fproviders\u002Faws_resolvers.go`). The injected `ProviderContext` allows you to lazy-load cloud SDK clients (like the AWS EC2 client) only when that specific provider's resources are encountered, keeping the core tool completely provider-agnostic. Custom resolvers take precedence over the auto-generated documentation mappings.\n\n### Building Locally\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fcoolapso\u002Ftfimport.git\ncd tfimport\ngo build .\u002F...\ngo run main.go --help\n```\n","tfimport 是一个基于 Go 语言的命令行工具，旨在自动化将现有基础设施导入到 Terraform 或 OpenTofu 状态文件的过程。它支持多工具集成（如 Terraform、Terragrunt 和 Tofu），能够智能识别数百种资源的特定导入格式，并且可以在离线状态下解析现有的 Terraform 计划文件。通过使用云提供商 SDK，tfimport 可以根据计划时已知的标签和属性查找不透明 ID，同时具备容错处理能力，能够优雅地跳过新创建的资源并处理速率限制。该工具适用于需要将已有基础设施纳入 Terraform 管理的各种场景，特别是当手动导入变得繁琐时。","2026-06-11 04:06:01","CREATED_QUERY"]