terraform-azurerm-set-diff-analyzer
它能做什么
这个工具用于分析 Azure 资源的 Terraform 计划输出。它能帮你找出那些看起来改动很大、实际上却很小甚至根本不存在的变更。这些“假变更”是由某些 Azure 资源处理列表项的方式造成的。
适用场景
- ✓当 `terraform plan` 显示大量变更,但你实际上只添加或删除了一项时。
- ✓当 Application Gateway 或 Load Balancer 等资源显示“all elements changed”(所有元素都已变更)时。
- ✓当你想在 CI/CD 流程中自动过滤掉假变更时。
技能链接
https://github.com/github/awesome-copilot/blob/main/skills/terraform-azurerm-set-diff-analyzer/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请分析我的 Terraform 计划,告诉我哪些变更是真实的,哪些是假的。”
每周 5 个新技能,1 分钟读完。
工作原理
该工具会把 Terraform 计划输出与一份已知会导致这类“假变更”的资源和属性清单进行比对。它重点关注那些因顺序问题而产生变更的 “Set” 类型属性。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Terraform AzureRM Set Diff Analyzer
A skill to identify "false-positive diffs" in Terraform plans caused by AzureRM Provider's Set-type attributes and distinguish them from actual changes.
When to Use
terraform planshows many changes, but you only added/removed a single element- Application Gateway, Load Balancer, NSG, etc. show "all elements changed"
- You want to automatically filter false-positive diffs in CI/CD
Background
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.
These "false-positive diffs" don't actually affect the resources, but they make reviewing terraform plan output difficult.
Prerequisites
- Python 3.8+
If Python is unavailable, install via your package manager (e.g., apt install python3, brew install python3) or from python.org.
Basic Usage
# 1. Generate plan JSON output
terraform plan -out=plan.tfplan
terraform show -json plan.tfplan > plan.json
# 2. Analyze
python scripts/analyze_plan.py plan.json
Troubleshooting
python: command not found: Usepython3instead, or install PythonModuleNotFoundError: Script uses only standard library; ensure Python 3.8+
Detailed Documentation
- scripts/README.md - All options, output formats, exit codes, CI/CD examples
- references/azurerm_set_attributes.md - Supported resources and attributes
常见问题
什么是“假变更”?
指 Terraform 计划中显示出来、但实际上并不会改变 Azure 中资源的变更。这是因为某些列表的比较依据是项目的顺序,而不是内容本身。
需要安装什么吗?
需要。你的电脑上要安装 Python 3.8 或更高版本。
怎么使用?
先生成 Terraform 计划文件(`terraform plan -out=plan.tfplan` 和 `terraform show -json plan.tfplan > plan.json`),然后用生成的文件运行 Python 脚本(`python scripts/analyze_plan.py plan.json`)。
详情
作者的原始描述
Analyze 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, Firewall, Front Door, NSG, and other resources with Set-type attributes that cause spurious diffs due to internal ordering ch
repo: github/awesome-copilot
热度
- GitHub 星标
- 40k
- 排名
- #7449
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
acquire-codebase-knowledge
40k帮你的智能体理解并编写现有代码项目的文档。它有助于新成员快速上手,或者快速了解项目架构。
acreadiness-assess
40k让你的智能体评估一个项目对 AI 的准备程度,并生成报告。它有助于了解项目在使用 AI 工具方面的准备情况。
acreadiness-generate-instructions
40k帮你的智能体根据评估结果编写 AI 工具的指令文件。它有助于改善 AI 与代码的交互方式,并弥补已发现的不足。
acreadiness-policy
40k让你的智能体协助制定或应用 AI 项目评估的政策。它有助于规范项目的评估方式,并确保合规。