Terraform search and import
Finds existing cloud resources with Terraform Search queries in .tfquery.hcl, generates resource and import blocks, and falls back to manual import for unsupported types. Use when bringing hand-made infrastructure under Terraform.
terraform-search-import- Author
- HashiCorp
- Source
- hashicorp/agent-skills/plugins/terraform/skills/terraform-search-import @ 5e30fa5
- License
- MPL-2.0
About this skill
What it does
The skill brings cloud resources that were created by hand under Terraform management. Its main route is Terraform Search, which needs Terraform 1.14 or later and a provider that implements list resources. The agent writes .tfquery.hcl files with list blocks: a provider reference, a provider-specific config with filters such as tag:Environment or instance-state-name, a limit, and optionally for_each over regions or variables. terraform query prints what matches; terraform query -generate-config-out=<file> writes a resource block plus an identity-based import block for each hit. The agent then cleans that code: it drops computed attributes such as arn and id, replaces hardcoded values with variables, renames all_0-style labels and sorts the result into files. terraform plan and terraform apply perform the import, and terraform state list with terraform show -json confirm it, without printing state, which holds secrets in plain text.
The skill makes the agent check support first. scripts/list_resources.sh [provider] reads terraform providers schema -json and prints the list resources each provider offers; it needs terraform and jq, and if .terraform is missing it runs terraform init -upgrade quietly. When the resource type is not supported or Terraform is older than 1.14, references/MANUAL-IMPORT.md takes over: find resources with the cloud's own CLI (AWS CLI examples for RDS, DynamoDB, API Gateway and SNS), write resource and import blocks by hand, plan and apply, plus a bash script that writes import blocks for every DynamoDB table.
When to use it, and when not
Use it to adopt infrastructure clicked together in a console, to see what an account actually holds, or to move from manual provisioning to code.
It does not help with resources already in state, where an import fails, and it does nothing for building new infrastructure.
How to run it
We do not copy this skill: its files are under MPL-2.0, a file-level copyleft licence outside the set we copy under. Install it from HashiCorp's repository with the button to the source: one skill via npx skills add hashicorp/agent-skills/plugins/terraform/skills/terraform-search-import, or the whole terraform plugin, in Claude Code claude plugin marketplace add hashicorp/agent-skills and claude plugin install terraform@hashicorp. In Codex: codex plugin marketplace add hashicorp/agent-skills, then install terraform from /plugins and start a new session. In Claude Code, the plugin's skill may appear as /terraform:terraform-search-import.
- Claude Code:
/terraform-search-import, or ask for the skill by name. - Codex:
$terraform-search-import. - Cursor: type
/in the Agent chat and pickterraform-search-import.
Example: /terraform-search-import Find the running EC2 instances tagged Owner=platform in us-west-2 and eu-west-1 and generate import config for them.
How it differs from similar skills
No other skill in the catalog brings existing, unmanaged resources under infrastructure as code. Cloudflare cf CLI can find and list existing resources from the terminal, but only Cloudflare's, and it imports nothing into Terraform. Within the pack, Terraform style guide is the target for the cleaned-up generated code, and Refactor Terraform into modules is the next step when the imported resources should move into a module with moved blocks.
Install
This skill is not copied to the catalog: its licence allows a copy only under the same licence, and the catalog does not copy under such licences. Install it from the author's repository.
Connect through AnyModel API
This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.
AnyModel