import-infrastructure-as-code
Lets your agent create infrastructure code from existing Azure resources. It maps dependencies and ensures configuration consistency.
What it does
This tool transforms your existing Azure infrastructure into Terraform code. It discovers your cloud resources and recreates them using standard modules (AVM), making management and replication easier.
When to use it
- ✓When you want to recreate an existing Azure infrastructure.
- ✓To turn Azure resources into code that can be versioned and reused.
- ✓When migrating or backing up infrastructure configurations.
Example of what to ask your AI
“Turn my resource group 'my-app' in subscription '12345678-abcd-1234-abcd-1234567890ab' into Terraform code using AVM modules.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The tool uses the Azure command-line interface (Azure CLI) to 'look' at your existing resources. Then, it searches for standard modules (Azure Verified Modules - AVM) that match these resources and generates the Terraform code.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add github/awesome-copilot --skill import-infrastructure-as-codeOr download just the file:
curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/import-infrastructure-as-code/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
…
FAQ
What are 'AVM modules'?
They are standardized, Microsoft-tested building blocks for creating Azure infrastructure with Terraform, ensuring consistency and security.
Do I need to have Terraform installed?
Yes, you need to have the Terraform CLI installed on your computer for the tool to generate and use the code.
What if an Azure resource doesn't have a corresponding AVM module?
The tool will try to document the situation and may suggest alternatives or indicate that the resource will need manual configuration.
Details
Original description by the author
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
Popularity
- GitHub stars
- 40k
- Ranking position
- #5192
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
acquire-codebase-knowledge
Helps your agent understand and document an existing code project. It's useful for onboarding new people or getting an overview of the architecture.
github/awesome-copilot
acreadiness-assess
Enables your agent to assess a project's readiness for AI and generate a report. It's useful for understanding how well a project is prepared to use AI tools.
github/awesome-copilot
acreadiness-generate-instructions
Helps your agent create instructions for AI tools based on an assessment. It's useful for improving how AI interacts with code and closing identified gaps.
github/awesome-copilot
acreadiness-policy
Enables your agent to help define or apply policies for AI project assessment. It's useful for standardizing how projects are evaluated and ensuring compliance.
github/awesome-copilot
Similar skills
bun-runtime
Has your agent use Bun to run, organize, and test code. It helps choose Bun over other tools and migrate existing projects.
affaan-m/ECC
database-migrations
Helps your agent make safe changes to databases. It ensures changes can be undone and minimizes downtime.
affaan-m/ECC
deployment-patterns
Sets up deployment and CI/CD workflows, containerization, and rollback strategies to ensure safe releases.
affaan-m/ECC