地形搜索导入

运维部署 社区

技能解读

当前原文的自动摘译,尚未人工审校。

决策树

主要工作流程 = 通过 az CLI 手动发现。始终与 azurerm ~> 4.0 配合使用。搜索工作流程是实验性的 - azurerm 提供商对 list_resource_schemas 的支持待定。使用手动发现作为可靠的默认设置。

规则

手动发现是主要路径 - 始终与 azurerm ~> 4.0 和 Azure CLI 配合使用; Terraform 搜索处于实验阶段,提供程序支持待定。 Pin 提供程序为 ~> 4.0 — azurerm 4.x 重命名了许多属性(allow_blob_public_access → allow_nested_items_to_be_public 等);固定到其他任何东西会导致导入后发生漂移应用前计划 - 始终在生成导入块后运行terraform plan;该计划应仅显示导入操作(不创建/销毁)

手动发现工作流程(主要)

三步过程:(1)通过az resource list发现现有资源(通过资源组、标签或特定于类型的命令,如az vm list); (2) 为每个块生成 resource + import 块(references/manual-import.md中的完整示例和批量导入脚本); (3) terraform plan(回顾:仅导入 — 不创建/销毁)→ terraform apply。

导入后:采用 AVM 模块

导入原始的azurerm_*资源后,使用moved {}块重构为AVM模块。请参阅terraform-patterns技能references/refactor-module.md获取指导。

与 Terraform MCP 集成

在导入工作流程中使用 Terraform MCP 工具: 工具 · 目的 mcp_terraform_search_providers · 验证提供程序中的资源类型支持 mcp_terraform_get_provider_details · 获取资源架构和导入 ID 格式 mcp_terraform_search_modules · 查找用于导入后重构的 AVM 模块

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
运维部署
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@tomevault-io · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
即装即用
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# Terraform Search & Import for Azure

Discover existing Azure resources and generate Terraform configuration for bulk import.

**References:**

- [Terraform Import](https://developer.hashicorp.com/terraform/language/import)
- [Terraform Search](https://developer.hashicorp.com/terraform/language/block/tfquery/list) (TF 1.14+)

---

## Decision Tree

```text
┌─ Identify target Azure resources
│
├─ PRIMARY: Manual Discovery via az CLI (always works)
│  └─ az resource list → create import blocks → terraform plan → apply
│
└─ SECONDARY: Terraform Search (EXPERIMENTAL)
   ├─ Check: terraform version >= 1.14?
   │  └─ NO → use Manual workflow
   ├─ Check: azurerm supports list_resource_schemas for this type?
   │  └─ UNKNOWN/NO → use Manual workflow
   └─ YES to both → use Search workflow
```

**Primary workflow = Manual Discovery** via `az` CLI. Always works with azurerm ~> 4.0.

**Search workflow is experimental** — `azurerm` provider support for `list_resource_schemas`
is TBD. Use Manual Discovery as the reliable default.

---

## Rules

- **Manual Discovery is the primary path** — always works with `azurerm ~> 4.0` and Azure CLI; Terraform Search is experimental and provider support is TBD
- **Pin provider to `~> 4.0`** — azurerm 4.x renamed many attributes (`allow_blob_public_access` → `allow_nested_items_to_be_public`, etc.); pinning to anything else causes drift after import
- **Plan before apply** — always run `terraform plan` after generating import blocks; the plan should show import actions ONLY (no creates / destroys)
- **Adopt AVM modules post-import** — raw `azurerm_*` is acceptable as a temporary state; refactor to `Azure/avm-res-*` modules with `moved {}` blocks (see `terraform-patterns` `references/refactor-module.md`)
- **Document the source** — in the imported `resource` block, comment the originating `az resource list` query so future runs can be reproduced
- **Out of scope**: Bicep code (use `azure-bicep-patterns`), new resource creation (use `terraform-patterns`), architecture decisions (use `azure-adr`)

## Manual Discovery Workflow (Primary)

Three-step procedure: (1) discover existing resources via `az resource list` (by resource
group, tag, or type-specific commands like `az vm list`); (2) generate `resource` + `import`
blocks for each (full examples and bulk import scripts in
[`references/manual-import.md`](references/manual-import.md)); (3) `terraform plan` (review:
imports only — no creates / destroys) → `terraform apply`.

Import ID format:
`/subscriptions/{sub}/resourceGroups/{rg}/providers/{type}/{name}`. The Azure-type ↔
Terraform-resource ↔ `az` CLI mapping table for the 8 most common services lives in
[`references/manual-import.md`](references/manual-import.md).

## Post-Import: Adopt AVM Modules

After importing raw `azurerm_*` resources, refactor to AVM modules using `moved {}` blocks.
See `terraform-patterns` skill `references/refactor-module.md` for guidance.

## Integration with Terraform MCP

Use Terraform MCP tools during import workflows:

| Tool                                      | Purpose                                      |
| ----------------------------------------- | -------------------------------------------- |
| `mcp_terraform_search_providers`          | Validate resource type support in provider   |
| `mcp_terraform_get_provider_details`      | Get resource schemas and import ID format    |
| `mcp_terraform_search_modules`            | Find AVM modules for post-import refactoring |
| `mcp_terraform_get_latest_module_version` | Get latest AVM module version                |

---

## Terraform Search Workflow (Experimental)

> **Warning**: Requires Terraform >= 1.14 and `azurerm` provider support for
> `list_resource_schemas` (TBD). Use Manual Discovery above as primary path.

Uses `.tfquery.hcl` files with `list` blocks to discover resources, then
`terraform query -generate-config-out=imported.tf` to generate config.
Clean generated output by removing computed attrs, adding variables, applying CAF naming.

---

## Reference Index

| File                          | Contents                                                         |
| ----------------------------- | ---------------------------------------------------------------- |
| `references/manual-import.md` | Detailed az CLI discovery, bulk import scripts, resource mapping |
| `scripts/list_resources.sh`   | Extract supported list resources from providers                  |

---
> Source: [aivandelindt/azure-agentic-infraops](https://github.com/aivandelindt/azure-agentic-infraops) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。