$npx -y skills add github/awesome-copilot --skill terraform-azurerm-set-diff-analyzerAnalyze Terraform plan JSON output for AzureRM Provider to distinguish between false-positive diffs (order-only changes in Set-type attributes) and actual resource changes. Use when reviewing terraform plan output for Azure resources like Application Gateway, Load Balancer, Firew
| 1 | # Terraform AzureRM Set Diff Analyzer |
| 2 | |
| 3 | A skill to identify "false-positive diffs" in Terraform plans caused by AzureRM Provider's Set-type attributes and distinguish them from actual changes. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - `terraform plan` shows many changes, but you only added/removed a single element |
| 8 | - Application Gateway, Load Balancer, NSG, etc. show "all elements changed" |
| 9 | - You want to automatically filter false-positive diffs in CI/CD |
| 10 | |
| 11 | ## Background |
| 12 | |
| 13 | Terraform's Set type compares by position rather than by key, so when adding or removing elements, all elements appear as "changed". This is a general Terraform issue, but it's particularly noticeable with AzureRM resources that heavily use Set-type attributes like Application Gateway, Load Balancer, and NSG. |
| 14 | |
| 15 | These "false-positive diffs" don't actually affect the resources, but they make reviewing terraform plan output difficult. |
| 16 | |
| 17 | ## Prerequisites |
| 18 | |
| 19 | - Python 3.8+ |
| 20 | |
| 21 | If Python is unavailable, install via your package manager (e.g., `apt install python3`, `brew install python3`) or from [python.org](https://www.python.org/downloads/). |
| 22 | |
| 23 | ## Basic Usage |
| 24 | |
| 25 | ```bash |
| 26 | # 1. Generate plan JSON output |
| 27 | terraform plan -out=plan.tfplan |
| 28 | terraform show -json plan.tfplan > plan.json |
| 29 | |
| 30 | # 2. Analyze |
| 31 | python scripts/analyze_plan.py plan.json |
| 32 | ``` |
| 33 | |
| 34 | ## Troubleshooting |
| 35 | |
| 36 | - **`python: command not found`**: Use `python3` instead, or install Python |
| 37 | - **`ModuleNotFoundError`**: Script uses only standard library; ensure Python 3.8+ |
| 38 | |
| 39 | ## Detailed Documentation |
| 40 | |
| 41 | - [scripts/README.md](scripts/README.md) - All options, output formats, exit codes, CI/CD examples |
| 42 | - [references/azurerm_set_attributes.md](references/azurerm_set_attributes.md) - Supported resources and attributes |