Terraform import
Import existing AWS, Azure, or GCP infrastructure into Terraform using the terraback MCP tools. Use when the user asks to import, codify, adopt, or bring existing cloud resources under Terraform management.From its SKILL.md
npx -y skills add bmoldo/terraback-plugin --skill terraform-importAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.7 KB, as published. Nobody here has run it
Import existing cloud infrastructure into Terraform
Use the terraback MCP tools to inventory live cloud resources, generate
Terraform HCL with import blocks, and verify the result with a read-only
terraform plan. All six tools are read-only or code-generation-only:
none of them import into state, apply, or mutate cloud infrastructure.
Prerequisites (check before starting)
- terraback is pip-installed and on PATH - the MCP server is launched as
terraback mcp. If the terraback tools are missing, tell the user topip install terrabackand re-add the server. - Read-only cloud credentials are configured in the environment the MCP
server runs in (ambient credential chain; tools never take credentials
as arguments): AWS
ReadOnlyAccess+SecurityAudit, AzureReaderon the subscription, GCProles/vieweron the project. terraform>= 1.5 is on PATH -verify_planrunsterraform init+terraform plan, and import blocks require Terraform 1.5+.
Scope semantics
Every provider-facing tool takes provider + scope:
aws: scope is a region, e.g."us-east-1". Optionalprofileselects a named AWS CLI profile.azure: scope is a subscription ID.gcp: scope is a project ID.
The canonical loop
Follow these steps in order. Confirm provider and scope with the user first.
1. Plan coverage
Call list_supported_resources (optionally with provider) and confirm
the resource types the user cares about are supported. Use the returned
type names in every later types argument.
2. Inventory
Call scan_infrastructure with provider and scope. Pass types to
narrow the scan - it is much faster than scanning everything. The result
contains summary.total and summary.counts_by_type. The full resource
list is inlined only up to 200 entries; for larger inventories the result
instead points at inventory_file - read that JSON file from disk to see
individual resources.
3. Target unmanaged resources (optional)
If the user already has Terraform state, call detect_unmanaged with
provider, scope, and state_files. v1 reads LOCAL state file paths
only - for remote backends (S3, azurerm, GCS, Terraform Cloud), run
terraform state pull > state.json first and pass that path. Work only
on the unmanaged resources it reports; never touch already-managed ones.
4. Codify
Call codify_batch with provider, scope, types, and an explicit
output_dir. Start with a small type subset rather than everything at
once. To skip already-managed resources, pass state_files plus
exclude_managed: true.
The Community tier caps a single call at 25 total resources. If the tool
returns {"error": "resource_cap_exceeded", ...}, nothing was written:
narrow the request using types or tag_filters (the error's
counts_by_type shows what to cut), or tell the user the Professional
tier removes the cap. Use codify_resource for a single known resource
ID; it is not capped.
5. Verify
Call verify_plan with terraform_dir set to the output directory. It
returns drift ("none", "drift_detected", or "plan_failed") and a
summary of imports, adds, changes, destroys.
6. Fix drift until clean
Pending imports are expected and are not drift. Adds, changes, and destroys are problems:
- Read
change_resources/add_resources/destroy_resourcesfrom the result, open the corresponding.tffiles inoutput_dir, and fix the specific attributes causing the diff. - If
driftis"plan_failed", read the returned error output, fix the invalid HCL or provider config, and re-run. - Re-run
verify_planafter each fix. Repeat untildriftis"none".
7. Hand off
Summarize for the user: files written (list the .tf files in
output_dir), resource counts by type, and any remaining warnings from
the tool results. State clearly that nothing has been imported or applied
yet, and give the next command (terraform apply performs the imports).
Rules
- Never edit the IDs inside generated
importblocks - they are the contract between the code and the live resource. - Prefer regenerating a resource (
codify_resource/codify_batch) over hand-editing whole files; hand-edit only targeted attributes when resolving drift. - Never run
terraform applyunless the user explicitly asks for it. - Do not invent tool parameters - the tool reference at https://docs.terraback.io/mcp-server/tool-reference/ is the authoritative contract.