跳到正文
Skillpedia
部署与云(DevOps)40k · #7449

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/terraform-azurerm-set-diff-analyzer/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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 plan shows 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: Use python3 instead, or install Python
  • ModuleNotFoundError: Script uses only standard library; ensure Python 3.8+

Detailed Documentation

常见问题

什么是“假变更”?

指 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能