
Aztfexport
- 45 installs
- 6 repo stars
- Updated July 22, 2026
- julianobarbosa/claude-code-skills
Helps with ai & agent building tasks.
About
aztfexport is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- aztfexport
- AI & Agent Building
- AI-coding skill
Aztfexport by the numbers
- 45 all-time installs (skills.sh)
- +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #7,680 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/julianobarbosa/claude-code-skills --skill aztfexportAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 45 |
|---|---|
| repo stars | ★ 6 |
| Last updated | July 22, 2026 |
| Repository | julianobarbosa/claude-code-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
aztfexport — Export Azure Resources to Terraform
Overview
aztfexport is a Microsoft tool that exports existing Azure resources into Terraform HCL + state. It reverse-engineers live Azure infrastructure into Terraform configurations. Use this for Azure-only workflows or Terraform versions before 1.14's native terraform query.
When to Use
- Export a single Azure resource to Terraform →
aztfexport resource - Export an entire resource group →
aztfexport resource-group - Export resources matching an Azure Resource Graph query →
aztfexport query - Bootstrapping IaC from existing Azure infrastructure
Use `terraform-search-import` skill instead when: Terraform >= 1.14 with terraform query + bulk import (multi-cloud, not Azure-specific).
Prerequisites
1. aztfexport installed: brew install aztfexport (macOS) or see GitHub releases 2. Azure CLI authenticated: az login + correct subscription selected 3. Architecture check (critical on macOS):
file $(which aztfexport) # Check binary arch
uname -m # Check system archIf mismatch (e.g., x86_64 binary on arm64 Mac), reinstall the correct architecture version.
Workflow
Step 1: Discover the Resource ID
Use Azure CLI to find the resource ID. See references/RESOURCE-DISCOVERY.md for patterns by resource type.
Generic fallback:
az resource list --query "[?name=='RESOURCE_NAME']" -o tableStep 2: Validate aztfexport Binary
file $(which aztfexport)
uname -m
aztfexport --versionArchitecture mismatch causes cryptic failures. Always verify before first use on a new machine.
Step 3: Run aztfexport
Single resource:
aztfexport resource \
--non-interactive \
--plain-ui \
-o ./terraform-export \
"/subscriptions/SUB_ID/resourceGroups/RG/providers/TYPE/NAME"Resource group:
aztfexport resource-group \
--non-interactive \
--plain-ui \
-o ./terraform-export \
RESOURCE_GROUP_NAMEAzure Resource Graph query:
aztfexport query \
--non-interactive \
--plain-ui \
-o ./terraform-export \
"resources | where name == 'MY_RESOURCE'"Step 4: Review Generated Files
ls ./terraform-export/
# Expect: main.tf, provider.tf, terraform.tfstate, import.tf (sometimes)main.tf— generated HCL withres-0style resource namesprovider.tf— AzureRM provider configurationterraform.tfstate— imported state file- Consider renaming
res-0to descriptive names (update both HCL and state)
Step 5: Verify
cd ./terraform-export
terraform init
terraform planA clean plan (no changes) confirms successful export. Minor diffs may appear for computed attributes — review and suppress with lifecycle { ignore_changes } if appropriate.
Critical Flags
| Flag | Purpose | When Required |
|---|---|---|
--non-interactive | Skip interactive prompts | Always in CI/headless/Claude |
--plain-ui | Disable TUI (terminal UI) | Always pair with `--non-interactive` — without it, fails when no /dev/tty |
-o <dir> | Output directory | Always (must be empty or non-existent) |
--append | Append to existing Terraform dir | When adding to existing config (but see gotcha below) |
--overwrite | Overwrite existing files | When re-exporting to same directory |
--hcl-only | Generate HCL without importing state | When you only need the code |
Gotchas & Troubleshooting
| Problem | Cause | Solution |
|---|---|---|
Binary crashes silently or exec format error | Architecture mismatch (x86 on ARM Mac) | Run file $(which aztfexport) + uname -m, reinstall correct arch |
--non-interactive alone fails | No /dev/tty in headless environments | Always pair with --plain-ui |
| "directory is not empty" error | Output dir has files | Use -o <fresh-dir> or --overwrite |
--append fails on non-empty dir without state | aztfexport expects existing Terraform state | Use -o to a fresh subdirectory instead |
| Can't find Azure resource ID | Resource type unknown or wrong API | Try multiple az commands — see RESOURCE-DISCOVERY.md |
res-0 style names in output | Default aztfexport naming | Rename post-export in both HCL and state |
terraform plan shows diffs after export | Computed/server-side attributes | Review diffs — use ignore_changes for benign ones |
Example: Export an Activity Log Alert
# Step 1: Find the resource ID
az monitor activity-log alert list -g myResourceGroup \
--query "[?name=='my-alert'].id" -o tsv
# Step 2: Export
aztfexport resource \
--non-interactive \
--plain-ui \
-o ./alert-export \
"/subscriptions/xxxx/resourceGroups/myRG/providers/Microsoft.Insights/activityLogAlerts/my-alert"
# Step 3: Verify
cd ./alert-export
terraform init
terraform plan---
Gotchas
- Architecture mismatch between the aztfexport binary and the AzureRM provider's CGO bindings — Apple Silicon needs ARM64 build, x86 binary on M-series silently degrades.
- Resource-name regex defaults exclude special chars — resources with
.in the name (FQDNs, etc.) are skipped silently. - Generated `import` blocks (Terraform 1.5+) vs `state import` commands — aztfexport now writes blocks; older workflows expecting state-import calls break.
- `--include-role-assignment` is OFF by default — RBAC is left out of state, which is usually exactly what you don't want.
- Provider version pinning: aztfexport pins to specific AzureRM versions in its imports; mismatched provider in your target stack causes spurious plan diffs.
- Non-interactive (`-n`) skips name customization — auto-generated TF names like
azurerm_storage_account_001end up in your code permanently if not reviewed.
Azure Resource Discovery — CLI Patterns
Azure CLI commands for finding resource IDs by type. All commands output the resource ID needed for aztfexport resource.
Generic Fallback
Works for any resource type when you know the name:
# By name
az resource list --query "[?name=='RESOURCE_NAME']" -o table
# By name with resource ID only
az resource list --query "[?name=='RESOURCE_NAME'].id" -o tsv
# By type
az resource list --resource-type "Microsoft.Compute/virtualMachines" -o table
# By resource group
az resource list -g RESOURCE_GROUP_NAME -o tableMonitor Alerts
Azure alerts span 3 different API endpoints — check each if unsure of the alert type:
# Metric alerts
az monitor metrics alert list -g RG_NAME --query "[?name=='ALERT_NAME'].id" -o tsv
# Scheduled query rules (log alerts)
az monitor scheduled-query list -g RG_NAME --query "[?name=='ALERT_NAME'].id" -o tsv
# Activity log alerts
az monitor activity-log alert list -g RG_NAME --query "[?name=='ALERT_NAME'].id" -o tsvTip: If you don't know which type, run all three in parallel.
Compute
# Virtual Machines
az vm list -g RG_NAME --query "[].{name:name, id:id}" -o table
# VM Scale Sets
az vmss list -g RG_NAME --query "[].{name:name, id:id}" -o table
# Disks
az disk list -g RG_NAME --query "[].{name:name, id:id}" -o tableNetworking
# Virtual Networks
az network vnet list -g RG_NAME --query "[].{name:name, id:id}" -o table
# Subnets (need vnet name)
az network vnet subnet list -g RG_NAME --vnet-name VNET_NAME --query "[].{name:name, id:id}" -o table
# Network Security Groups
az network nsg list -g RG_NAME --query "[].{name:name, id:id}" -o table
# Public IPs
az network public-ip list -g RG_NAME --query "[].{name:name, id:id}" -o table
# Load Balancers
az network lb list -g RG_NAME --query "[].{name:name, id:id}" -o table
# Application Gateways
az network application-gateway list -g RG_NAME --query "[].{name:name, id:id}" -o table
# NAT Gateways
az network nat gateway list -g RG_NAME --query "[].{name:name, id:id}" -o tableStorage
# Storage Accounts
az storage account list -g RG_NAME --query "[].{name:name, id:id}" -o tableKey Vault
az keyvault list -g RG_NAME --query "[].{name:name, id:id}" -o tableKubernetes (AKS)
az aks list -g RG_NAME --query "[].{name:name, id:id}" -o tableDatabases
# Azure SQL Server
az sql server list -g RG_NAME --query "[].{name:name, id:id}" -o table
# Azure SQL Database (need server name)
az sql db list -g RG_NAME -s SERVER_NAME --query "[].{name:name, id:id}" -o table
# CosmosDB
az cosmosdb list -g RG_NAME --query "[].{name:name, id:id}" -o table
# PostgreSQL Flexible Server
az postgres flexible-server list -g RG_NAME --query "[].{name:name, id:id}" -o tableApp Services
# Web Apps / App Services
az webapp list -g RG_NAME --query "[].{name:name, id:id}" -o table
# Function Apps
az functionapp list -g RG_NAME --query "[].{name:name, id:id}" -o table
# App Service Plans
az appservice plan list -g RG_NAME --query "[].{name:name, id:id}" -o tableContainer Registry
az acr list -g RG_NAME --query "[].{name:name, id:id}" -o tableAzure Resource Graph (Cross-Subscription)
For finding resources across multiple subscriptions:
# By name across all subscriptions
az graph query -q "resources | where name == 'RESOURCE_NAME' | project id, name, type, resourceGroup"
# By type across all subscriptions
az graph query -q "resources | where type == 'microsoft.compute/virtualmachines' | project id, name, resourceGroup"Requires az extension add --name resource-graph if not installed.