Generated banner for Terraform Azurerm Set Diff Analyzer
Generated logo for Terraform Azurerm Set Diff Analyzer

Terraform Azurerm Set Diff Analyzer

GitHubOfficialFirst committed by torumakabeDistributed by GitHub

  • Skill
  • Review and audit
  • Software development
  • MIT
  • Low risk
  • Has scripts

From the author

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 changes.
— the description by torumakabe

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The Terraform AzureRM Set Diff Analyzer helps developers distinguish between actual infrastructure changes and spurious diffs in Terraform plans. Because Terraform's Set type does not guarantee order, adding or removing elements can cause the provider to report that all elements in a set have changed. This tool parses the JSON output of a Terraform plan and uses a configurable definition file to identify these false-positive diffs, making it easier to review infrastructure changes for complex Azure resources like Application Gateways, Load Balancers, and Network Security Groups.

What it does

  • Analyzes Terraform plan JSON output to identify false-positive diffs.
  • Distinguishes between actual resource changes and ordering-only changes in Set-type attributes.
  • Supports nested Set-type attribute structures for complex Azure resources.
  • Uses a JSON-based definition file to map resource attributes to their unique identifiers.
  • Provides a command-line interface for integration into CI/CD pipelines.

When to use it

  • When a Terraform plan shows excessive changes despite minor modifications.
  • When reviewing plans for resources like Application Gateway, Load Balancer, or NSG.
  • When you need to clean up plan output for easier human review.
  • When automating infrastructure validation in CI/CD to ignore non-functional diffs.

Advantages

  • Reduces noise in Terraform plan reviews.
  • Prevents confusion caused by AzureRM Provider's Set-type attribute behavior.
  • Highly configurable via external JSON definitions for new or updated resources.
  • Lightweight implementation using only Python standard libraries.

Usage examples

“How do I analyze my Terraform plan for false positives?”
Generate the plan JSON using 'terraform show -json plan.tfplan > plan.json' and run 'python scripts/analyze_plan.py plan.json' to see the filtered results.
“How can I add a new Azure resource to the analyzer?”
Update the azurerm_set_attributes.json file by adding the resource type and identifying the key attribute (e.g., 'name') that uniquely identifies elements within the Set.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/github/terraform-azurerm-set-diff-analyzer/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip terraform-azurerm-set-diff-analyzer.zip -d .agents/skills

Documentation by torumakabe

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

Files

references/azurerm_set_attributes.md

AzureRM Set-Type Attributes Reference

This document explains the overview and maintenance of azurerm_set_attributes.json.

Last Updated: January 28, 2026

Overview

azurerm_set_attributes.json is a definition file for attributes treated as Set-type in the AzureRM Provider. The analyze_plan.py script reads this JSON to identify "false-positive diffs" in Terraform plans.

What are Set-Type Attributes?

Terraform's Set type is a collection that does not guarantee order. Therefore, when adding or removing elements, unchanged elements may appear as "changed". This is called a "false-positive diff".

JSON File Structure

Basic Format
{
  "resources": {
    "azurerm_resource_type": {
      "attribute_name": "key_attribute"
    }
  }
}
  • key_attribute: The attribute that uniquely identifies Set elements (e.g., name, id)

  • null: When there is no key attribute (compare entire element)

Nested Format

When a Set attribute contains another Set attribute:

{
  "rewrite_rule_set": {
    "_key": "name",
    "rewrite_rule": {
      "_key": "name",
      "condition": "variable",
      "request_header_configuration": "header_name"
    }
  }
}
  • _key: The key attribute for that level's Set elements

  • Other keys: Definitions for nested Set attributes

Example: azurerm_application_gateway
"azurerm_application_gateway": {
  "backend_address_pool": "name",           // Simple Set (key is name)
  "rewrite_rule_set": {                     // Nested Set
    "_key": "name",
    "rewrite_rule": {
      "_key": "name",
      "condition": "variable"
    }
  }
}

Maintenance

Adding New Attributes
  1. Check Official Documentation

    • Search for the resource in Terraform Registry

    • Verify the attribute is listed as "Set of ..."

    • Some resources like azurerm_application_gateway have Set attributes noted explicitly

  2. Check Source Code (more reliable)

    • Search for the resource in AzureRM Provider GitHub

    • Confirm Type: pluginsdk.TypeSet in the schema definition

    • Identify attributes within the Set's Schema that can serve as _key

  3. Add to JSON

    "azurerm_new_resource": {
      "set_attribute": "key_attribute"
    }
  4. Test

    # Verify with an actual plan
    python3 scripts/analyze_plan.py your_plan.json
Identifying Key Attributes
Common Key AttributeUsage
nameNamed blocks (most common)
idResource ID reference
locationGeographic location
addressNetwork address
host_nameHostname
nullWhen no key exists (compare entire element)
analyze_plan.py

Analyzes Terraform plan JSON to identify false-positive diffs.

# Basic usage
terraform show -json plan.tfplan | python3 scripts/analyze_plan.py

# Read from file
python3 scripts/analyze_plan.py plan.json

# Use custom attribute file
python3 scripts/analyze_plan.py plan.json --attributes /path/to/custom.json

Supported Resources

Please refer to azurerm_set_attributes.json directly for currently supported resources:

# List resources
jq '.resources | keys' azurerm_set_attributes.json

Key resources:

  • azurerm_application_gateway - Backend pools, listeners, rules, etc.

  • azurerm_firewall_policy_rule_collection_group - Rule collections

  • azurerm_frontdoor - Backend pools, routing

  • azurerm_network_security_group - Security rules

  • azurerm_virtual_network_gateway - IP configuration, VPN client configuration

Notes

  • Attribute behavior may differ depending on Provider/API version

  • New resources and attributes need to be added as they become available

  • Defining all levels of deeply nested structures improves accuracy

Requirements and compatibility

Written for: GitHub Copilot

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs a command-line tool, Needs Python

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

First committed by
GitHub avatar of torumakabetorumakabe
Publisher
GitHub (Official)
Distributed by
GitHub
Source
github/awesome-copilot · skills/terraform-azurerm-set-diff-analyzer · commit 797337f
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
torumakabe

AutoGineer is not affiliated with or endorsed by torumakabe or GitHub.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download terraform-azurerm-set-diff-analyzer.zip