SkillAtlasSkill 详情

import-infrastructure-as-code

Powered by Awesome Copilot GitHub contributors from allcontributors.org

审核状态:已审核Quality 72Security 70

复制安装命令

用 Codex 或 Claude 安装复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它先审查 Skill 页面再帮你安装。

复制前请先查看来源、License 和安全提示。

项目 README

来源文件:README.md

抓取于 2026年7月29日

🤖 Awesome GitHub Copilot

Powered by Awesome Copilot GitHub contributors from allcontributors.org

A community-created collection of custom agents, instructions, skills, hooks, workflows, and plugins to supercharge your GitHub Copilot experience.

[!TIP] Explore the full collection on the website → awesome-copilot.github.com

The website offers full-text search and filtering across hundreds of resources, plus the Learning Hub for guides and tutorials.

Using this collection in an AI agent? A machine-readable llms.txt is available with structured listings of all agents, instructions, and skills.

📖 Learning Hub

New to GitHub Copilot customization? The Learning Hub on the website offers curated articles, walkthroughs, and reference material — covering everything from core concepts like agents, skills, and instructions to hands-on guides for hooks, agentic workflows, MCP servers, and the Copilot coding agent.

What's in this repo

ResourceDescriptionBrowse
🤖 AgentsSpecialized Copilot agents that integrate with MCP serversAll agents →
📋 InstructionsCoding standards applied automatically by file patternAll instructions →
🎯 SkillsSelf-contained folders with instructions and bundled assetsAll skills →
🔌 PluginsCurated bundles of agents and skills for specific workflowsAll plugins →
🍳 CookbookCopy-paste-ready recipes for working with Copilot APIs—

Install a Plugin

For most users, the Awesome Copilot marketplace is already registered in the Copilot CLI/VS Code, so you can install a plugin directly:

copilot plugin install <plugin-name>@awesome-copilot

If you are using an older Copilot CLI version or a custom setup and see an error that the marketplace is unknown, register it once and then install:

copilot plugin marketplace add github/awesome-copilot
copilot plugin install <plugin-name>@awesome-copilot

Contributing

See CONTRIBUTING.md · AGENTS.md for AI agent guidance · Security · Code of Conduct

The customizations here are sourced from third-party developers. Please inspect any agent and its documentation before installing.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Aaron Powell

Matt Soucoup

Troy Simeon Taylor

Abbas

Peter Strömberg

Daniel Scott-Raynsford

John Haugabook

Pavel Simsa

Harald Kirschner

Muhammad Ubaid Raza

Tom Meschter

Aung Myo Kyaw

JasonYeMSFT

Jon Corbin

troytaylor-msft

Emerson Delatorre

Burke Holland

Kent Yao

Daniel Meppiel

Gordon Lam

Mads Kristensen

Shinji Takenaka

spectatora

Yohan Lasorsa

Vamshi Verma

James Montemagno

Alessandro Fragnani

Ambily

krushideep

devopsfan

Tugdual Grall

Oren Me

Mike Rousos

Justin Yoo

Guilherme do Amaral Alves

Griffin Ashe

Ashley Childress

Adrien Clerbois

ANGELELLI David

Mark Davis

Matt Vevang

Maximilian Irro

NULLchimp

Peter Karda

Saul Dolgin

Shubham Gaikwad

Theo van Kraay

Tianqi Zhang

Will 保哥

Yuta Matsumura

anschnapp

hizahizi-hizumi

黃健旻 Vincent Huang

Bruno Borges

Steve Magne

Shane Neuville

André Silva

Allen Greaves

Amelia Payne

BBoyBen

Brooke Hamilton

Christopher Harrison

Dan

Dan Wahlin

Debbie O'Brien

Ed Harrod

Genevieve Warren

Guillaume

Henrique Nunes

Jeremiah Snee

Kartik Dhiman

Kristiyan Velkov

msalaman

Per Søderlind

Peter Smulovics

Ravish Rathod

Rick Smit

Rob Simpson

Robert Altman

Salih

Sebastian Gräf

Sebastien DEGODEZ

Sergiy Smyrnov

SomeSolutionsArchitect

Stu Mace

Søren Trudsø Mahon

Tj Vita

Peli de Halleux

Paulo Morgado

Paul Crane

Pamela Fox

Oskar Thornblad

Nischay Sharma

Nikolay Marinov

Nik Sachdeva

Nick Taylor

Nick Brady

Nathan Stanford Sr

Máté Barabás

Mike Parker

Mike Kistler

Giovanni de Almeida Martins

이상현

Ankur Sharma

Wendy Breiding

voidfnc

shane lee

sdanzo-hrb

sauran

samqbush

pareenaverma

oleksiyyurchyna

oceans-of-time

kshashank57

Meii

factory-davidgu

dangelov-qa

BenoitMaucotel

benjisho-aidome

Yuki Omoto

Will Schultz

Waren Gonzaga

Vincent Koc

Victor Williams

Ve Sharma

Vasileios Lahanas

Udaya Veeramreddygari

Tài Lê

Tsubasa Ogawa

Troy Witthoeft (glsauto)

Gerald Versluis

George Dernikos

Gautam

Furkan Enes

Florian Mücke

Felix Arjuna

Eldrick Wega

Dobri Danchev

Diego Gamboa

Derek Clair

David Ortinau

Daniel Abbatt

CypherHK

Craig Bekker

Christophe Peugnet

Christian Lechner

Chris Harris

Artem Saveliev

Antoine Rey

Ankit Das

Aline Ávila

Alexander Martinkevich

Aleksandar Dunchev

Alan Sprecacenere

Akash Kumar Shaw

Abdi Daud

AIAlchemyForge

4regab

Miguel P Z

Michael Fairchild

Michael A. Volz (Flynn)

Michael

Mehmet Ali EROL

Max Prilutskiy

Matteo Bianchi

Mark Noble

Manish Jayaswal

Luke Murray

Louella Creemers

Sai Koumudi Kaluvakolanu

Kenny White

KaloyanGenev

Kim Skov Rasmussen

Julien Dubois

José Antonio Garrido

Joseph Gonzales

Jorge Balderas

John Papa

John

Joe Watkins

Jan de Vries

Jakub Jareš

Jackson Miller

Ioana A

Hunter Hogan

Hashim Warren

Gonzalo

Gisela Torres

Shibi Ramachandran

lupritz

Héctor Benedicte

Ted Vilutis

Anthony Shaw

Chris McKee

CASTResearchLabs

白水淳

Imran Siddique

共产主义接班人

Ivan Charapanau

Tadas Labudis

Alvin Ashcraft

Jan Krivanek

Gregg Cochran

Josh N

ian zhang

Garrett Siegel

Roberto Perez

Dan Velton

Lee Reilly

Daniel Coelho

Vahid Faraji

Ashley Wolf

Noah Jenkins

Jeremy Kohn

Harri Sipola

Toru Makabe

Pham Tien Thuan Phat

Benji Shohet

Amaury Levé

Tim Deschryver

Mohammad Asad Alahmadi

fondoger

Yuval Avidani

Csaba Iváncza

Tim Heuer

lance2k

Andrea Liliana Griffiths

Ajith Raghavan

Catherine Han

Igor Shishkin

Burrito Verde

Joseph Van der Wee

Luiz Bon

Sanjay Ramassery Babu

Russ Rimmerman [MSFT]

Roberto Perez

Shehab Sherif

Smit Patel

Steven Vore

Subhashis Bhowmik

Tim Mulholland

Niels Laute

Pavel Sulimau

PrimedPaul

Zhiqi Pu

Ramyashree Shetty

ZdaPhp

pigd0g

rahulbats

suyask-msft

tagedeep

tinkeringDev

Travis Hill

Utkarsh patrikar

Yauhen

Yiou Li

Yuki Omoto

Abhi Bavishi

augustus-0

Branislav Buna

connerlambden

David Raygoza

Diego Porto Ritzel

Eric Scherlinger

Fatih

Felipe Pessoto

François

Geoffrey Casaubon

Anddd7

Anders Eide

Aymen

Kevin van Zonneveld

Luis Cantero

MV Karan

Marcel Deutzer

Jon Galloway

Josh Beard

Julian

Simon Kurtz

Temitayo Afolabi

JoeVenner

Pasindu Premarathna

ecosystem

Punit

Onur Senturk

Andrew Stellman

Jeonghoon Lee

Satya K

Samik Roy

Simina Pasat

Tyler Garner

Vijay Chegu

DTIBeograd

Anmol Behl

Brad Kinnard

Chad Bentz

Marcello Cuoghi

Josh Johanning

jennyf19

Saravanan Rajaraman

Patel Dhruv

Renee Noble

jjpinto

moeyui1

mohammadali2549

Vladislav Guzey

aparna198809

Ed McAdams

Emil Andersson

Mikael

Mrigank Singh

Jim Bennett

Alishahzad1903

Antonio Villanueva

Tim Hanewich

ming

Scott O'Hara

Salih

Shailesh

Shubham Jiyani

Srinivas Vaddi

Philippe D

Rajesh Goldy

dstrupl

wuwen

Tilak Patel

Vijay Bandi

Zixuan Jiang

Dennis Lembree

Dev Shah

Falco

AJ

Anush

Ayush Saklani

Carlos Alexandro Becker

Mangokernel

Mario Codes

Gonzalo Fleming

Steve Magne

Sertxito

Rayner Zeng

ilderaj

mvanderbend-msoft

Parveen Sharma

pmorong

vinod kumar

Vidhart Bhatia

Xiaoyun Ding

denis-a-evdokimov

Adriano Nogueira

Aezan

Andy Anderson

Kweku Dzata

Marcel

Navaneeth Reddy

James

Joseph Counts

Neha Mandge

Srikanth Patchava

Thomas Ray

Nixon Kurian

Petr Stupka

Pieter de Bruin

sudeepghatak

tlietz

dawright22

Alejandro Fernando Suarez Gomez

Burak Bayır

MUHAMMAD SAMIULLAH

Nikola Metulev

Joseph Kasprzyk

Lovy Jain

kimtth

Akash Dwivedi

Suren K
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

📚 Additional Resources

™️ Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

开发与工程

中风险

  • 来源需自行核对维护者身份。
  • 包含脚本或命令调用,安装前请复核。
  • 可能需要外部 token、网络权限或第三方服务。
  • 未检测到高风险命令。
  • 扫描发现:2 条。

Codex — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/github/awesome-copilot.git
  3. 将 "skills/import-infrastructure-as-code" 文件夹复制到 Codex 的 skills 目录中。
  4. 重启 Codex 让新的 skill 生效。

Codex — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Codex 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Codex 让新的 skill 生效。

Claude Code — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/github/awesome-copilot.git
  3. 将 "skills/import-infrastructure-as-code" 文件夹复制到 Claude Code 的 skills 目录中。
  4. 重启 Claude Code 让新的 skill 生效。

Claude Code — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Claude Code 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Claude Code 让新的 skill 生效。

Cursor — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/github/awesome-copilot.git
  3. 将 "skills/import-infrastructure-as-code" 文件夹复制到 Cursor 的 skills 目录中。
  4. 重启 Cursor 让新的 skill 生效。

Cursor — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Cursor 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Cursor 让新的 skill 生效。

GitHub Copilot — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/github/awesome-copilot.git
  3. 将 "skills/import-infrastructure-as-code" 文件夹复制到 GitHub Copilot 的 skills 目录中。
  4. 重启 GitHub Copilot 让新的 skill 生效。

GitHub Copilot — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 GitHub Copilot 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 GitHub Copilot 让新的 skill 生效。

Windsurf — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/github/awesome-copilot.git
  3. 将 "skills/import-infrastructure-as-code" 文件夹复制到 Windsurf 的 skills 目录中。
  4. 重启 Windsurf 让新的 skill 生效。

Windsurf — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Windsurf 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Windsurf 让新的 skill 生效。
查看 SKILL.md 原文
name: import-infrastructure-as-code
description: '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 files ready for validation and planning across any Azure resource type.'

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

ParameterRequiredDefaultDescription
subscription-idNoActive CLI contextAzure subscription used for subscription-scope discovery and context setting
resource-group-nameNoNoneAzure resource group used for resource-group-scope discovery
resource-idNoNoneOne 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 --ids arguments (for example az 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.json with all discovered resources and their metadata, including dependencies and references.
  • EXPORTED-ARCHITECTURE.MD file 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

Note: The following links always point to the latest version of the CSV files on the main branch. As intended, this means the files may change over time. If you require a point-in-time version, consider using a specific release tag in the URL.

  • Terraform Resource Modules: https://raw.githubusercontent.com/Azure/Azure-Verified-Modules/refs/heads/main/docs/static/module-indexes/TerraformResourceModules.csv
  • Terraform Pattern Modules: https://raw.githubusercontent.com/Azure/Azure-Verified-Modules/refs/heads/main/docs/static/module-indexes/TerraformPatternModules.csv
  • Terraform Utility Modules: https://raw.githubusercontent.com/Azure/Azure-Verified-Modules/refs/heads/main/docs/static/module-indexes/TerraformUtilityModules.csv

Individual Module information

Use the web tool or another suitable MCP method to get module information if not available locally in the .terraform folder.

Use AVM sources:

  • Registry: https://registry.terraform.io/modules/Azure/<module>/azurerm/latest
  • GitHub: https://github.com/Azure/terraform-azurerm-avm-res-<service>-<resource>

Prefer AVM modules over handwritten azurerm_* resources when an AVM module exists.

When fetching module information from GitHub repositories, the README.md file in the root of the repository typically contains all detailed information about the module, for example: https://raw.githubusercontent.com/Azure/terraform-azurerm-avm-res--/refs/heads/main/README.md

5a) Read the Module README Before Writing Any Code (Mandatory)

This step is not optional. Before writing a single line of HCL for a module, fetch and read the full README for that module. Do not rely on knowledge of the raw azurerm provider or prior experience with other AVM modules.

For each selected AVM module, fetch its README:

https://raw.githubusercontent.com/Azure/terraform-azurerm-avm-res-<service>-<resource>/refs/heads/main/README.md

Or if the module is already downloaded after terraform init:

cat .terraform/modules/<module_key>/README.md

From the README, extract and record before writing code:

  1. Required Inputs — every input the module requires. Any child resource listed here (NICs, extensions, subnets, public IPs) is managed inside the module. Do not create standalone module blocks for those resources.
  2. Optional Inputs — the exact Terraform variable names and their declared type. Do not assume they match the raw azurerm provider argument names or block shapes.
  3. Usage examples — check what resource group identifier is used (parent_id vs resource_group_name), how child resources are expressed (inline map vs separate module), and what syntax each input expects.

Apply module rules as patterns, not assumptions

Use the lessons below as examples of the type of mismatch that often causes imports to fail. Do not assume these exact names apply to every AVM module. Always verify each selected module's README and variables.tf.

avm-res-compute-virtualmachine (any version)

  • network_interfaces is a Required Input. NICs are owned by the VM module. Never create standalone avm-res-network-networkinterface modules alongside a VM module — define every NIC inline under network_interfaces.
  • TrustedLaunch is expressed through the top-level booleans secure_boot_enabled = true and vtpm_enabled = true. The security_type argument exists only under os_disk for Confidential VM disk encryption and must not be used for TrustedLaunch.
  • boot_diagnostics is a bool, not an object. Use boot_diagnostics = true; use the separate boot_diagnostics_storage_account_uri variable if a storage URI is needed.
  • Extensions are managed inside the module via the extensions map. Do not create standalone extension resources.

avm-res-network-virtualnetwork (any version)

  • This module is backed by the AzAPI provider, not azurerm. Use parent_id (the full resource group resource ID string) to specify the resource group, not resource_group_name.
  • Every example in the README shows parent_id; none show resource_group_name.

Generalized takeaway for all AVM modules:

  • Determine child resource ownership from Required Inputs before creating sibling modules.
  • Determine accepted variable names and types from Optional Inputs and variables.tf.
  • Determine identifier style and input shape from README usage examples.
  • Do not infer argument names from raw azurerm_* resources.

6) Generate Terraform Files

Before Writing Import Blocks — Inspect Module Source (Mandatory)

After terraform init downloads the modules, inspect each module's source files to determine the exact Terraform resource addresses before writing any import {} blocks. Never write import addresses from memory.

Step A — Identify the provider and resource label

grep "^resource" .terraform/modules/<module_key>/main*.tf

This reveals whether the module uses azurerm_* or azapi_resource labels. For example, avm-res-network-virtualnetwork exposes azapi_resource "vnet", not azurerm_virtual_network "this".

Step B — Identify child modules and nested paths

grep "^module" .terraform/modules/<module_key>/main*.tf

If child resources are managed in a sub-module (subnets, extensions, etc.), the import address must include every intermediate module label:

module.<root_module_key>.module.<child_module_key>["<map_key>"].<resource_type>.<label>[<index>]

Step C — Check for count vs for_each

grep -n "count\|for_each" .terraform/modules/<module_key>/main*.tf

Any resource using count requires an index in the import address. When count = 1 (e.g., conditional Linux vs Windows selection), the address must end with [0]. Resources using for_each use string keys, not numeric indexes.

Known import address patterns (examples from lessons learned)

These are examples only. Use them as templates for reasoning, then derive the exact addresses from the downloaded source code for the modules in your current import.

ResourceCorrect import to address pattern
AzAPI-backed VNetmodule.<vnet_key>.azapi_resource.vnet
Subnet (nested, count-based)module.<vnet_key>.module.subnet["<subnet_name>"].azapi_resource.subnet[0]
Linux VM (count-based)module.<vm_key>.azurerm_linux_virtual_machine.this[0]
VM NICmodule.<vm_key>.azurerm_network_interface.virtualmachine_network_interfaces["<nic_key>"]
VM extension (default deploy_sequence=5)module.<vm_key>.module.extension["<ext_name>"].azurerm_virtual_machine_extension.this
VM extension (deploy_sequence=1–4)module.<vm_key>.module.extension_<n>["<ext_name>"].azurerm_virtual_machine_extension.this
NSG-NIC associationmodule.<vm_key>.azurerm_network_interface_security_group_association.this["<nic_key>-<nsg_key>"]

Produce:

  • providers.tf with azurerm provider and required version constraints
  • main.tf with AVM module blocks and explicit dependencies
  • variables.tf for environment-specific values
  • outputs.tf for key IDs and endpoints
  • terraform.tfvars.example with placeholder values

Diff Live Properties Against Module Defaults (Mandatory)

After writing the initial configuration, compare every non-zero property of each discovered live resource against the default value declared in the corresponding AVM module's variables.tf. Any property where the live value differs from the module default must be set explicitly in the Terraform configuration.

Pay particular attention to the following property categories, which are common sources of silent configuration drift:

  • Timeout values (e.g., Public IP idle_timeout_in_minutes defaults to 4; live deployments often use 30)
  • Network policy flags (e.g., subnet private_endpoint_network_policies defaults to "Enabled"; existing subnets often have "Disabled")
  • SKU and allocation (e.g., Public IP sku, allocation_method)
  • Availability zones (e.g., VM zone, Public IP zone)
  • Redundancy and replication settings on storage and database resources

Retrieve full live properties with explicit az commands, for example:

az network public-ip show --ids <resource_id> --query "{idleTimeout:idleTimeoutInMinutes, sku:sku.name, zones:zones}" -o json
az network vnet subnet show --ids <resource_id> --query "{privateEndpointPolicies:privateEndpointNetworkPolicies, delegation:delegations}" -o json

Do not rely solely on az resource list output, which may omit nested or computed properties.

Pin module versions explicitly:

module "example" {
	source  = "Azure/<module>/azurerm"
	version = "<latest-compatible-version>"
}

7) Validate Generated Code

Run:

terraform init
terraform fmt -recursive
terraform validate
terraform plan

Expected output: no syntax errors, no validation errors, and a plan that matches discovered infrastructure intent.

Troubleshooting

ProblemLikely CauseAction
az command fails with authorization errorsWrong tenant/subscription or missing RBAC roleRe-run az login, verify subscription context, confirm required permissions
Discovery output is emptyIncorrect scope or no resources in scopeRe-check scope input and run scoped list/show command again
No AVM module found for a resource typeResource type not yet covered by AVMUse native azurerm_* resource for that type and document the gap
terraform validate failsMissing variables or unresolved dependenciesAdd required variables and explicit dependencies, then re-run validation
Unknown argument or variable not found in moduleAVM variable name differs from azurerm provider argument nameRead the module README variables.tf or Optional Inputs section for the correct name
Import block fails — resource not found at addressWrong provider label (azurerm_ vs azapi_), missing sub-module path, or missing [0] indexRun grep "^resource" .terraform/modules/<key>/main*.tf and grep "^module" to find exact address
terraform plan shows unexpected ~ update on imported resourceLive value differs from AVM module defaultFetch live property with az <resource> show, compare to module default, add explicit value
Child-resource module gives "provider configuration not present"Child resources declared as standalone modules even though parent module owns themCheck Required Inputs in README, remove incorrect standalone modules, and model child resources using the parent module's documented input structure
Nested child resource import fails with "resource not found"Missing intermediate module path, wrong map key, or missing indexInspect module blocks and count/for_each in source; build full nested import address including all module segments and required key/index
Tool tries to read ARM resource ID as file path or asks repeated scope questionsResource ID not treated as --ids input, or agent did not trust already-provided scopeTreat ARM IDs strictly as cloud identifiers, use az ... --ids ..., and stop re-prompting once one valid scope is present

Response Contract

When returning results, provide:

  1. Scope used (subscription, resource group, or resource IDs)
  2. Discovery files created
  3. Resource types detected
  4. AVM modules selected with versions
  5. Terraform files generated or updated
  6. Validation command results
  7. Open gaps requiring user input (if any)

Execution Rules for the Agent

  • Do not continue if scope is missing.
  • Do not claim successful import without listing discovered files and validation output.
  • Do not skip dependency mapping before generating Terraform.
  • Prefer AVM modules first; justify each non-AVM fallback explicitly.
  • Read the README for every AVM module before writing code. Required Inputs identify which child resources the module owns. Optional Inputs document exact variable names and types. Usage examples show provider-specific conventions (parent_id vs resource_group_name). Skipping the README is the single most common cause of code errors in AVM-based imports.
  • Never assume NIC, extension, or public IP resources are standalone. For any AVM module, treat child resources as parent-owned unless the README explicitly indicates a separate module is required. Check Required Inputs before creating sibling modules.
  • Never write import addresses from memory. After terraform init, grep the downloaded module source to discover the actual provider (azurerm vs azapi), resource labels, sub-module nesting, and count vs for_each usage before writing any import {} block.
  • Never treat ARM resource IDs as file paths. Resource IDs belong in Azure CLI --ids arguments and API queries, not file IO tools. Only read local files when a real workspace path is provided.
  • Minimize prompts when scope is already known. If subscription, resource group, or specific resource IDs are already provided, proceed with commands directly and only ask a follow-up when a command fails due to missing required context.
  • Do not declare the import complete until terraform plan shows 0 destroys and 0 unwanted changes. Telemetry + create resources are acceptable. Any ~ update or - destroy on real infrastructure resources must be resolved.

References

发现问题?提交给管理员复核

评分:

评论 (0)

暂无评论,成为第一个评论者吧!