import-infrastructure-as-code
Skill này làm gì
Công cụ này chuyển hạ tầng Azure hiện có của bạn thành mã Terraform. Nó tìm các tài nguyên đám mây của bạn và tạo lại chúng bằng các module chuẩn (AVM), giúp việc quản lý và nhân bản dễ dàng hơn.
Khi nào nên dùng
- ✓Khi bạn muốn tạo lại một hạ tầng Azure hiện có.
- ✓Khi bạn muốn biến tài nguyên Azure thành mã có thể quản lý phiên bản và tái sử dụng.
- ✓Khi bạn đang di chuyển hoặc sao lưu cấu hình hạ tầng.
Liên kết skill
https://github.com/github/awesome-copilot/blob/main/skills/import-infrastructure-as-code/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy chuyển resource group 'my-app' trong subscription '12345678-abcd-1234-abcd-1234567890ab' thành mã Terraform bằng các module AVM.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ dùng giao diện dòng lệnh Azure (Azure CLI) để “xem” các tài nguyên hiện có của bạn. Sau đó, nó tìm các module chuẩn (Azure Verified Modules - AVM) phù hợp với những tài nguyên này và tạo mã Terraform.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Import Infrastructure as Code (Azure -> Terraform with AVM)
Convert existing Azure infrastructure into maintainable Terraform code using discovery data and Azure Verified Modules.
When to Use This Skill
Use this skill when the user asks to:
- Import existing Azure resources into Terraform
- Generate IaC from live Azure environments
- Handle any Azure resource type supported by AVM (and document justified non-AVM fallbacks)
- Recreate infrastructure from a subscription or resource group
- Map dependencies between discovered Azure resources
- Use AVM modules instead of handwritten
azurerm_*resources
Prerequisites
- Azure CLI installed and authenticated (
az login) - Access to the target subscription or resource group
- Terraform CLI installed
- Network access to Terraform Registry and AVM index sources
Inputs
| Parameter | Required | Default | Description |
|---|---|---|---|
subscription-id |
No | Active CLI context | Azure subscription used for subscription-scope discovery and context setting |
resource-group-name |
No | None | Azure resource group used for resource-group-scope discovery |
resource-id |
No | None | One or more Azure ARM resource IDs used for specific-resource-scope discovery |
At least one of subscription-id, resource-group-name, or resource-id is required.
Step-by-Step Workflows
1) Collect Required Scope (Mandatory)
Request one of these scopes before running discovery commands:
- Subscription scope:
<subscription-id> - Resource group scope:
<resource-group-name> - Specific resources scope: one or more
<resource-id>values
Scope handling rules:
- Treat Azure ARM resource IDs (for example
/subscriptions/.../providers/...) as cloud resource identifiers, not local file system paths. - Use resource IDs only with Azure CLI
--idsarguments (for exampleaz resource show --ids <resource-id>). - Never pass resource IDs to file-reading commands (
cat,ls,read_file, glob searches) unless the user explicitly says they are local file paths. - If the user already provided one valid scope, do not ask for additional scope inputs unless required by a failing command.
- Do not ask follow-up questions that can be answered from already-provided scope values.
If scope is missing, ask for it explicitly and stop.
2) Authenticate and Set Context
Run only the commands required for the selected scope.
For subscription scope:
az login
az account set --subscription <subscription-id>
az account show --query "{subscriptionId:id, name:name, tenantId:tenantId}" -o json
Expected output: JSON object with subscriptionId, name, and tenantId.
For resource group or specific resource scope, az login is still required but az account set is optional if the active context is already correct.
When using specific resource scope, prefer direct --ids-based commands first and avoid extra discovery prompts for subscription or resource group unless needed for a concrete command.
3) Run Discovery Commands
Discover resources using the selected scopes. Ensure to fetch all necessary information for accurate Terraform generation.
# Subscription scope
az resource list --subscription <subscription-id> -o json
# Resource group scope
az resource list --resource-group <resource-group-name> -o json
# Specific resource scope
az resource show --ids <resource-id-1> <resource-id-2> ... -o json
Expected output: JSON object or array containing Azure resource metadata (id, type, name, location, tags, properties).
4) Resolve Dependencies Before Code Generation
Parse exported JSON and map:
- Parent-child relationships (for example: NIC -> Subnet -> VNet)
- Cross-resource references in
properties - Ordering for Terraform creation
IMPORTANT: Generate the following documentation and save it to a docs folder in the root of the project.
exported-resources.jsonwith all discovered resources and their metadata, including dependencies and references.EXPORTED-ARCHITECTURE.MDfile with a human-readable architecture overview based on the discovered resources and their relationships.
5) Select Azure Verified Modules (Required)
Use the latest AVM version for each resource type.
Terraform Registry
- Search for "avm" + resource name
- Filter by "Partner" tag to find official AVM modules
- Example: Search "avm storage account" → filter by Partner
Official AVM Index
…
Câu hỏi thường gặp
“AVM modules” là gì?
Đó là các khối xây dựng tiêu chuẩn, đã được Microsoft kiểm thử, để tạo hạ tầng Azure bằng Terraform, giúp đảm bảo tính nhất quán và an toàn.
Tôi có cần cài Terraform không?
Có, bạn cần cài giao diện dòng lệnh Terraform (Terraform CLI) trên máy tính để công cụ tạo và sử dụng mã.
Nếu một tài nguyên Azure không có module AVM tương ứng thì sao?
Công cụ sẽ cố gắng ghi lại tình trạng này và có thể đề xuất giải pháp thay thế, hoặc cho bạn biết tài nguyên đó cần được cấu hình thủ công.
Chi tiết
Mô tả gốc của tác giả
Import existing Azure resources into Terraform using Azure CLI discovery and Azure Verified Modules (AVM). Use when asked to reverse-engineer live Azure infrastructure, generate Infrastructure as Code from existing subscriptions/resource groups/resource IDs, map dependencies, derive exact import addresses from downloaded module source, prevent configuration drift, and produce AVM-based Terraform f
repo: github/awesome-copilot
Độ phổ biến
- Sao GitHub
- 40k
- Vị trí xếp hạng
- #7249
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
acquire-codebase-knowledge
40kGiúp agent của bạn hiểu và ghi tài liệu cho một dự án mã nguồn có sẵn. Hữu ích khi đón thành viên mới hoặc nắm tổng quan về kiến trúc.
acreadiness-assess
40kGiúp agent của bạn đánh giá mức độ sẵn sàng cho AI của dự án và tạo báo cáo. Hữu ích để biết dự án đã sẵn sàng dùng công cụ AI đến đâu.
acreadiness-generate-instructions
40kGiúp agent của bạn tạo hướng dẫn cho công cụ AI dựa trên kết quả đánh giá. Hữu ích để cải thiện cách AI làm việc với mã và khắc phục các khoảng trống.
acreadiness-policy
40kGiúp agent của bạn xác định hoặc áp dụng chính sách đánh giá dự án bằng AI. Hữu ích để chuẩn hóa cách đánh giá dự án và đảm bảo tuân thủ.
Skill tương tự
openclaw-update
394kGiúp agent của bạn cập nhật OpenClaw Gateway đang có, chọn cách cập nhật phù hợp với cách cài đặt và giữ phiên làm việc của bạn hoạt động.
diagnose-gateway
394kGiúp agent của bạn tìm hiểu vì sao OpenClaw Gateway bị lỗi bằng cách kiểm tra cài đặt, kênh và cổng mà không thay đổi gì.
crabbox-apps
394kGiúp agent của bạn mở và chạy một app trên máy đám mây tạm thời, rồi hiển thị giao diện của nó trong thanh bên của chat.